[英]Could not connect to the database. (pyodbc.Error) [Microsoft][ODBC Driver 17 for SQL Server]Login failed for user '%user%'. (18456) (SQLDriverConnect)
We've migrated our SQL server from version 2012 to 2017, and now we can't connect to the database.我们已将 SQL 服务器从版本 2012 迁移到 2017,现在我们无法连接到数据库。
(pyodbc.Error) ('28000', "[28000]
[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user
'usintranet'. (18456) (SQLDriverConnect)")
Does anyone have the same issue?有没有人有同样的问题?
We use python36 and python3.我们使用python36和python3。
The paremeters for the code below are:以下代码的参数是:
name: 'producao:integracao18'
type: 'mssql'
conf:
user: 'userlist'
password: 'password2019'
host: '176.1.1.1'
port: 134
database: 'CRM'
The method for connecting to the database is:连接数据库的方法是:
def connect(self, driver, conf):
"""Connects to a database and returns the connection instance"""
conn = None
# see http://docs.sqlalchemy.org/en/latest/core/engines.html
if driver == 'sqlite':
conn = f"sqlite:///{conf['local']}"
elif driver == 'mysql':
conn = f"mysql://{conf['usuario']}:{conf['senha']}@{conf['host']}:{conf['porta']}/{conf['database']}"
elif driver == 'mssql':
conn = f"mssql+pyodbc://{conf['usuario']}:{conf['senha']}@{conf['host']}:{conf['porta']}/{conf['database']}"
# MSSQL needs pyodbc and a specific driver, you can check the available ones with pyodbc.drivers()
conn += '?driver=ODBC+Driver+17+for+SQL+Server'
I haven't encountered this error, but the first thing I'd verify is that your ODBC settings are still properly configured on your host computer.我没有遇到此错误,但我首先要验证的是您的 ODBC 设置仍然在您的主机上正确配置。
I'm not familiar with pyodbc, but if the tip above doesn't help, you should verify that your version of pyodbc is compatible with the ODBC driver you're using.我不熟悉 pyodbc,但如果上面的提示没有帮助,您应该验证您的 pyodbc 版本是否与您正在使用的 ODBC 驱动程序兼容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.