Web2py: pass parameters to db Connection()

孤者浪人 提交于 2020-01-07 01:51:05

问题


In web2py, in gluon/contrib/pymysql/connections.py there is a function that creates a new mySQL connection:

def __init__(self, host="localhost", user=None, passwd="",
             db=None, port=3306, unix_socket=None,

Is there any way to pass parameters to this function from web2py?


回答1:


As noted at the very end of this section of the documentation, you can specify a dictionary of driver_args when instantiating DAL:

db = DAL(<connection_string>,
         driver_args=dict(host='localhost', port=3306, ...))


来源:https://stackoverflow.com/questions/36648700/web2py-pass-parameters-to-db-connection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!