简体   繁体   English

无法连接到数据库 - python ODBC

[英]Cannot connect to database - python ODBC

I am struggling to connect to an ODBC DSN using python 3. The ODBC driver is a read only driver from a SCADA package vendor not a standard MS or Oracle driver type.我正在努力使用 python 3 连接到 ODBC DSN。ODBC 驱动程序是来自 SCADA 包供应商的只读驱动程序,而不是标准的 MS 或 Oracle 驱动程序类型。

I have tried pyodbc:我试过pyodbc:

import pyodbc
...
  connectionString = 'dsn=myDSN'
  connection = pyodbc.connect(connectionString)

Which yields the error:这会产生错误:

('HY000', '[HY000] [Simba][ODBC] Not enough information provided to connection to data source and specified to not prompt for more information. (10042) (SQLDriverConnect); [HY000] [Simba][ODBC] Not enough information provided to connection to data source and specified to not prompt for more information. (10042)')

I have tried odbc:我试过 odbc:

import odbc
...
  conn = odbc.odbc('myDSN')

Which yields the similar error:这会产生类似的错误:

[Simba][ODBC] Not enough information provided to connection to data source and specified to not prompt for more information. in LOGIN

I have third party .net forms program which I decompliled and I can see uses a standard System.Data.Odbc.OdbcConnection with the same simple connection string as the pyodbc method above and it works fine...我有我反编译的第三方 .net 表单程序,我可以看到使用标准 System.Data.Odbc.OdbcConnection 和与上面 pyodbc 方法相同的简单连接字符串,它工作正常......

I have been over the pyodbc documentation but I can't see any other parameters or attributes I need to set to get this to work, or at least have it prompt for the extra information I am not supplying.我已经阅读了 pyodbc 文档,但看不到我需要设置的任何其他参数或属性,或者至少让它提示我没有提供的额外信息。

Has anyone encountered this before?有没有人遇到过这个?

Thanks in advance.提前致谢。

Mike.麦克风。

尝试这样做:

sql_conn = pyodbc.connect(r'DRIVER={SQL Server};SERVER=10.10.10.10;DATABASE=test; trusted_connection=yes')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM