如何使用python中的pyodbc连接到本地优势数据库? [英] How can i connect to local advantage database using pyodbc in python?
问题描述
据我了解,要使用pyodbc,您必须
As far as i can understand to use pyodbc you have to
cnxn = pyodbc.connect('DRIVER={Advantage ODBC Driver};SERVER=local;DataDirectory=\\AltaDemo\Demo\AltaPoint.add;DATABASE=AltaPoint;UID=admin;PWD=admin;ServerTypes=1;')
cursor = cnxn.cursor()
这是我运行此命令时从控制台收到的错误 错误:("IM002","[IM002] [Microsoft] [ODBC驱动程序管理器]数据源名称未找到且未指定默认驱动程序(0)(SQLDriverConnect)")
This is the error i get from the console when i run this Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
推荐答案
驱动程序的名称为Advantage StreamlineSQL ODBC
,因此最起码的连接字符串为:
The name of the driver is Advantage StreamlineSQL ODBC
, so the bare minimum connect string is:
DRIVER={Advantage StreamlineSQL ODBC};DataDirectory=D:\Temp
其他最佳选择是:
DefaultType=Advantage
User ID=xxx
Password=xxx
ServerTypes=2
AdvantageLocking=ON
CharSet=ANSI
Language=ANSI
Description=My ADS connection
Locking=Record
MaxTableCloseCache=25
MemoBlockSize=64
Rows=False
Compression=Internet
CommType=TCP_IP
TLSCertificate=
TLSCommonName=
TLSCiphers=
DDPassword=Dictionary Password
EncryptionType=
FIPS=False
TrimTrailingSpaces=True
SQLTimeout=600
RightsChecking=OFF
如果要使用本地服务器,则必须传递ServerTypes=1
,就像原始字符串中已经存在的那样.
If you want to use the Local Server you have to pass ServerTypes=1
like you already have in your original string.
有关更多选项和文档,另请参见:
For more options and documentation see also:
- The official documentation
- ConnectionStrings.com
这篇关于如何使用python中的pyodbc连接到本地优势数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!