简体   繁体   English

无法连接到数据库。 (pyodbc.Error) [Microsoft][用于 SQL 服务器的 ODBC 驱动程序 17]用户“%user%”登录失败。 (18456) (SQLDriverConnect)

[英]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.

相关问题 [Microsoft] [用于SQL Server的ODBC驱动程序17]登录超时已过期(0)(SQLDriverConnect)') - [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)') 登录失败 (pyodbc.InterfaceError) ('28000', "[28000] [Microsoft][ODBC SQL 服务器驱动程序][SQL Server]用户 'xxxx' 登录失败 - Logon failed (pyodbc.InterfaceError) ('28000', "[28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'xxxx' pyodbc.OperationalError: SQL Server 不存在或访问被拒绝。 (17) (SQLDriverConnect); [08001] ODBC SQL Server 驱动程序][ - pyodbc.OperationalError: SQL Server does not exist or access denied. (17) (SQLDriverConnect); [08001] ODBC SQL Server Driver][ pyodbc.OperationalError: ('HYT00', u'[HYT00] [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]登录超时过期 (0) (SQLDriverConnect)') - pyodbc.OperationalError: ('HYT00', u'[HYT00] [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired (0) (SQLDriverConnect)') pyodbc.DataError:('22018',“[22018] [Microsoft] [ODBC SQL Server驱动程序] [SQL Server]转换失败]错误 - pyodbc.DataError: ('22018',"[22018] [Microsoft][ODBC SQL Server Driver][SQL Server]Conversion failed ] error 在Mac上使用SQL Server ODBC时出错:[unixODBC] [驱动程序管理器]无法打开lib'SQL Server的ODBC驱动程序17':找不到文件(0)(SQLDriverConnect)“) - Error Using SQL Server ODBC on Mac: [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)") ('IM004',“[IM004] [Microsoft] [ODBC驱动程序管理器] SQL_HANDLE_ENV上的驱动程序SQLAllocHandle失败(0)(SQLDriverConnect)”)错误 - ('IM004', “[IM004] [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed (0) (SQLDriverConnect)”) error pyodbc.Error: ('07002', '[07002] [Microsoft][ODBC Microsoft Access Driver] 参数太少。预期为 9。(-3010) (SQLExecDirectW)') - pyodbc.Error: ('07002', '[07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 9. (-3010) (SQLExecDirectW)') pyodbc.Error:找不到数据源名称,并且没有指定默认驱动程序(0)(SQLDriverConnect)') - pyodbc.Error: Data source name not found, and no default driver specified (0) (SQLDriverConnect)') pyodbc.ProgrammingError '42000',[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]找不到数据类型'TEXT'。 (104220) (SQLExecDirectW) - pyodbc.ProgrammingError '42000', [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Cannot find data type 'TEXT'. (104220) (SQLExecDirectW)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM