How can i connect to local advantage database using pyodbc in python?

拥有回忆 提交于 2019-12-17 21:14:32

问题


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()

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)')


回答1:


The name of the driver is Advantage StreamlineSQL ODBC, so the bare minimum connect string is:

DRIVER={Advantage StreamlineSQL ODBC};DataDirectory=D:\Temp

Other optinal options are:

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    

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


来源:https://stackoverflow.com/questions/33532699/how-can-i-connect-to-local-advantage-database-using-pyodbc-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!