看了web.py源码,关于连接数据库的函数如下(webpy/web/db.py):
1133 _databases = {}
1134 def database(dburl=None, **params):
1135 """Creates appropriate database using params.
1136
1137 Pooling will be enabled if DBUtils module is available.
1138 Pooling can be disabled by passing pooling=False in params.
1139 """
1140 dbn = params.pop('dbn')
1141 if dbn in _databases:
1142 return _databases[dbn](**params)
1143 else:
1144 raise UnknownDB, dbn
可以看出的是,dburl的确没有起到作用,注释里面也说了: Creates appropriate database using params。不过一般连接mysql数据库通过以下参数连接的话,应该是可以连接上的吧。(我没有试过远程,所以不敢肯定。)
import web
db = db.database(
dbn="mysql",
db="dbname",
host="host",
port=3306,
user="user",
pw="password"
)