我编写了一个 Python 脚本来连接到 Azure 中的 SQL 数据库,但收到以下错误:
9002 (28000):需要 SSL 连接。请指定 SSL 选项 然后重试。
显然我需要包含 SSL 凭据,但考虑到配置文件的其余格式,我不确定如何执行此操作。
我目前有一个字典,其中包含数据库访问凭据,格式为
'key' : 'value'
。
我见过的 SSL 参数似乎位于其他字典中或者是非字符串变量。无论如何,我只是需要有人告诉我......
这是我的配置文件中的字典,当然事物的实际名称已更改。
config = {
'user': 'username@database',
'password':'mypassword',
'host':'hostname.database.windows.net',
'database':'databasename'
}
谢谢!
你可以尝试一下:
from sqlalchemy import create_engine
connect_args = {
"ssl": {
"ssl_ca": "path of ssl cert"
}
}
engine = create_engine(dbstring, connect_args=connect_args)