添加Unix socket连接方法
This commit is contained in:
@@ -489,6 +489,17 @@ def get_database_url():
|
|||||||
encoded_user = quote_plus(config.mysql_user)
|
encoded_user = quote_plus(config.mysql_user)
|
||||||
encoded_password = quote_plus(config.mysql_password)
|
encoded_password = quote_plus(config.mysql_password)
|
||||||
|
|
||||||
|
# 检查是否配置了Unix socket连接
|
||||||
|
if config.mysql_unix_socket:
|
||||||
|
# 使用Unix socket连接
|
||||||
|
encoded_socket = quote_plus(config.mysql_unix_socket)
|
||||||
|
return (
|
||||||
|
f"mysql+pymysql://{encoded_user}:{encoded_password}"
|
||||||
|
f"@/{config.mysql_database}"
|
||||||
|
f"?unix_socket={encoded_socket}&charset={config.mysql_charset}"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# 使用标准TCP连接
|
||||||
return (
|
return (
|
||||||
f"mysql+pymysql://{encoded_user}:{encoded_password}"
|
f"mysql+pymysql://{encoded_user}:{encoded_password}"
|
||||||
f"@{config.mysql_host}:{config.mysql_port}/{config.mysql_database}"
|
f"@{config.mysql_host}:{config.mysql_port}/{config.mysql_database}"
|
||||||
|
|||||||
Reference in New Issue
Block a user