pymysql參數(shù)詳解

參數(shù) 解釋

host 數(shù)據(jù)庫(kù)服務(wù)器地址,默認(rèn) localhost
user 用戶名,默認(rèn)為當(dāng)前程序運(yùn)行用戶
password 登錄密碼,默認(rèn)為空字符串
database 默認(rèn)操作的數(shù)據(jù)庫(kù)
port 數(shù)據(jù)庫(kù)端口,默認(rèn)為 3306
bind_address 當(dāng)客戶端有多個(gè)網(wǎng)絡(luò)接口時(shí),指定連接到主機(jī)的接口。參數(shù)可以是主機(jī)名或IP地址。
unix_socket unix 套接字地址,區(qū)別于 host 連接
read_timeout 讀取數(shù)據(jù)超時(shí)時(shí)間,單位秒,默認(rèn)無(wú)限制
write_timeout 寫(xiě)入數(shù)據(jù)超時(shí)時(shí)間,單位秒,默認(rèn)無(wú)限制
charset 數(shù)據(jù)庫(kù)編碼
connect_timeout 連接超時(shí)時(shí)間,默認(rèn) 10,最小 1,最大 31536000
sql_mode 指定默認(rèn)的 SQL_MODE
cursorclass 設(shè)置默認(rèn)的游標(biāo)類型
init_command 當(dāng)連接建立完成之后執(zhí)行的初始化 SQL 語(yǔ)句
autocommit 是否自動(dòng)提交,默認(rèn)不自動(dòng)提交,參數(shù)值為 None 表示以服務(wù)器為準(zhǔn)
max_allowed_packet 發(fā)送給服務(wù)器的最大數(shù)據(jù)量,默認(rèn)為 16MB
defer_connect 是否惰性連接,默認(rèn)為立即連接
db 參數(shù) database 的別名
passwd 參數(shù) password 的別名
read_default_file Specifies my.cnf file to read these parameters from under the [client] section.
conv Conversion dictionary to use instead of the default one. This is used to provide custom marshalling and unmarshaling of types.
use_unicode Whether or not to default to unicode strings. This option defaults to true for Py3k.
client_flag Custom flags to send to MySQL. Find potential values in constants.CLIENT.
ssl A dict of arguments similar to mysql_ssl_set()’s parameters. For now the capath and cipher arguments are not supported.
read_default_group Group to read from in the configuration file.
local_infile Boolean to enable the use of LOAD DATA LOCAL command. (default: False)
auth_plugin_map A dict of plugin names to a class that processes that plugin. The class will take the Connection object as the argument to the constructor. The class needs an authenticate method taking an authentication packet as an argument. For the dialog plugin, a prompt(echo, prompt) method can be used (if no authenticate method) for returning a string from the user. (experimental)
server_public_key SHA256 authenticaiton plugin public key value. (default: None)
binary_prefix Add _binary prefix on bytes and bytearray. (default: False)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容