本文介紹了Web2py:將參數傳遞給 db Connection()的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
在 web2py 中,在 gluon/contrib/pymysql/connections.py 中有一個函數可以創建一個新的 mySQL 連接:
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,
有沒有辦法從 web2py 向這個函數傳遞參數?
Is there any way to pass parameters to this function from web2py?
推薦答案
如這部分的文檔,你可以在實例化時指定driver_args
的字典<代碼>DAL:
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, ...))
這篇關于Web2py:將參數傳遞給 db Connection()的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!