DataBase ConnectionString (good)

Database EngineConnectionString
DBASE (using ODBC)Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=C:/path/to/database
Excel (using ODBC)Driver={Microsoft Excel Driver (*.xls)};DriverID=790;Dbq=C:/path/to/spreadsheet;DefaultDir=C:/path/to/defaultdir
Excel (using OLE DB)Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Path/To/sheet.xls;
Access (using ODBC)Driver={Microsoft Access Driver (*.mdb)};Dbq=C:/path/to/database.mdb;Uid=username;Pwd=password

You can also pass additional options -- for example Exclusive=1; sets it to be opened in exclusive mode.
Access (using OLE DB) Using standard security
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/path/to/database.mdb;User Id=username;Password=somepassword;

Using Workgroup security
str="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=database.mdb;JET OLEDB:System Database=mysystem.mdw;"
oConn.Open(str, "my_user_name", "my_password")
Firebird Remote Database
Provider='LCPI.IBProvider';Data Source='remotehost:C:/path/to/database.fdb';User ID='username';Password='pwd';Auto Commit=true;

The above is reported to work for a Firebird database by Edward Diamond (ediamond at water dot ca dot gov). I would presume that it could work on a local Firebird server, simply by removing "remotehost" from the string above. Edward reports that even simple queries don't work without the "Auto Commit" part in the connection string.
MySQL (using ODBC) Local Database
Driver={MySQL ODBC 3.51 Driver};Server=localhost;User=username;Password=mypassword;Database=mydatabase;

Remote Database
Driver={MySQL ODBC 3.51 Driver};Server=192.168.1.100;Port=3306;User=username;Password=mypassword;Database=mydatabase;

There are more parameters that can be set (for example, Option, which controls several connection properties such as logging, packet size limits etc.) See section 3.3 (Connection Parameters) of the MyODBC manual for more information.
MySQL (using OLE DB)Provider=MySQLProv;Server=192.168.1.100;Port=3306;User=username;Password=mypassword;Database=mydatabase;

If you have the datasource already set up:
Provider=MySQLProv;Data Source=name_of_datasource;

You will need to download and install MyOleDB first. Last time I checked MyOLEDB was no longer maintained.
Oracle (using ODBC)Driver={Microsoft ODBC for Oracle};Server=MyOracleServer;Uid=username;Pwd=password

See the MSDN library for additional options.
Oracle (using OLE DB) Using OLE DB provider from Microsoft
Provider=MSDAORA;Data Source=MyOracleDB;User Id=username;Password=password
See the MSDN library for additional options.

Using OLE DB provider from Oracle
Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=username;Password=password
SQL Server (using ODBC) Standard Security
Driver={SQL Server};Server=192.168.1.100;Uid=username;Pwd=password;Database=dbname;

Trusted Connection
Simply add Trusted_Connection=yes to the above string.

See MSDN Library for more options.
SQL Server (using OLE DB)Provider=SQLOLEDB.1;Data Source=192.168.1.100;Uid=username;Pwd=password;Database=dbname;

See MSDN Library for more options.
com_error Traceback (most recent call last) File D:\anaconda3\Lib\site-packages\adodbapi\adodbapi.py:91, in connect(*args, **kwargs) 90 try: # connect to the database, using the connection information in kwargs ---> 91 co.connect(kwargs) 92 return co File D:\anaconda3\Lib\site-packages\adodbapi\adodbapi.py:266, in Connection.connect(self, kwargs, connection_maker) 265 try: --> 266 self.connector.Open() # Open the ADO connection 267 except api.Error: File <COMObject ADODB.Connection>:2, in Open(self, ConnectionString, UserID, Password, Options) File D:\anaconda3\Lib\site-packages\win32com\client\dynamic.py:355, in CDispatch._ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args) 354 def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args): --> 355 result = self._oleobj_.InvokeTypes( 356 *(dispid, LCID, wFlags, retType, argTypes) + args 357 ) 358 return self._get_good_object_(result, user, resultCLSID) com_error: (-2147352567, '发生意外。', (0, 'ADODB.Connection', '未找到提供程序。该程序可能未正确安装。', 'C:\\Windows\\HELP\\ADO270.CHM', 1240655, -2146824582), None) During handling of the above exception, another exception occurred: OperationalError Traceback (most recent call last) Cell In[3], line 6 4 import numpy as np 5 import matplotlib.pyplot as plt ----> 6 from adodbapi.examples.xls_read import sheet File D:\anaconda3\Lib\site-packages\adodbapi\examples\xls_read.py:25 21 filename = "xx.xls" 23 constr = "Provider=%s;Data Source=%s;%s" % (driver, filename, extended) ---> 25 conn = adodbapi.connect(constr) 27 try: # second command line argument will be worksheet name -- default to first worksheet 28 sheet = sys.argv[2] File D:\anaconda3\Lib\site-packages\adodbapi\adodbapi.py:95, in connect(*args, **kwargs) 93 except Exception as e: 94 message = 'Error opening connection to "%s"' % co.connection_string ---> 95 raise api.OperationalError(e, message) OperationalError: (com_error(-2147352567, '发生意外。', (0, 'ADODB.Connection', '未找到提供程序。该程序可能未正确安装。', 'C:\\Windows\\HELP\\ADO270.CHM', 1240655, -2146824582), None), 'Error opening connection to "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=-f;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1;""')
08-13
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值