[python-win32] AccessDB 2007 (S, Sachin (NSN - IN/Bangalore))

Zev Spitz shivisi at nana10.co.il
Thu Aug 23 18:29:34 CEST 2012


That connection string works if you're using the pyodbc library, which 
uses ODBC under the hood.
The questioner is using win32com to get at the ADODB.Connection object, 
which uses a different connection string format.

Zev Spitz

On 8/23/2012 4:38 PM, Ahmed, Shakir wrote:
>
> You can try this connection string too:
>
> DBfile = 'path /mymdb.mdb’ or  ‘path/myaccdb.accdb’
>
> conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb, 
> *.accdb)};DBQ='+DBfile, autocommit=True)
>
> cursor = conn.cursor()
>
> *From:*python-win32-bounces+shahmed=sfwmd.gov at python.org 
> [mailto:python-win32-bounces+shahmed=sfwmd.gov at python.org] *On Behalf 
> Of *Zev Spitz
> *Sent:* Thursday, August 23, 2012 7:40 AM
> *To:* python-win32 at python.org
> *Subject:* [python-win32] AccessDB 2007 (S, Sachin (NSN - IN/Bangalore))
>
> A connection string for ADO for Access looks like this:
> conn.Open('Provider=Microsoft.ACE.OLEDB.12.0;Data 
> Source=C:\\temp\\Database1.accdb')
>
> The other stuff looks like the connection string for an ODBC connection.
> If you don't have Office 2007 or later installed, then you need the 
> download at the link you provided. Otherwise, you have no need for it.
>
> Zev Spitz
>
> On 8/23/2012 1:00 PM, python-win32-request at python.org 
> <mailto:python-win32-request at python.org> wrote:
>
>     Send python-win32 mailing list submissions to
>
>         python-win32 at python.org  <mailto:python-win32 at python.org>
>
>       
>
>     To subscribe or unsubscribe via the World Wide Web, visit
>
>         http://mail.python.org/mailman/listinfo/python-win32
>
>     or, via email, send a message with subject or body 'help' to
>
>         python-win32-request at python.org  <mailto:python-win32-request at python.org>
>
>       
>
>     You can reach the person managing the list at
>
>         python-win32-owner at python.org  <mailto:python-win32-owner at python.org>
>
>       
>
>     When replying, please edit your Subject line so it is more specific
>
>     than "Re: Contents of python-win32 digest..."
>
>       
>
>       
>
>     Today's Topics:
>
>       
>
>         1. AccessDB 2007 (S, Sachin (NSN - IN/Bangalore))
>
>       
>
>       
>
>     ----------------------------------------------------------------------
>
>       
>
>     Message: 1
>
>     Date: Thu, 23 Aug 2012 17:27:11 +0800
>
>     From: "S, Sachin (NSN - IN/Bangalore)"<sachin.s at nsn.com>  <mailto:sachin.s at nsn.com>
>
>     To:<python-win32 at python.org>  <mailto:python-win32 at python.org>
>
>     Subject: [python-win32] AccessDB 2007
>
>     Message-ID:
>
>         <6CB66254BEA4AD42B4BE7BECC123D33C019531C0 at SGSIEXC025.nsn-intra.net>  <mailto:6CB66254BEA4AD42B4BE7BECC123D33C019531C0 at SGSIEXC025.nsn-intra.net>
>
>     Content-Type: text/plain; charset="us-ascii"
>
>       
>
>     Hi,
>
>     I am facing some problems while accessing the Microsoft Access Database
>
>     2007, using win32com. The code and errors are given below.
>
>     I also tried the steps in the link but to no avail:
>
>       
>
>     http://www.microsoft.com/en-us/download/confirmation.aspx?id=23734
>
>       
>
>     Could you help, or also if you know of a any other way of accessing the
>
>     database using the win32com module.
>
>       
>
>     Version:
>
>     ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
>
>     Python 2.7.2 (default, Jun 24 2011, 12:22:14) [MSC v.1500 64 bit
>
>     (AMD64)] on win32
>
>       
>
>     Operating System: Windows 7
>
>       
>
>     Code:
>
>     try:
>
>          import sys
>
>          from win32com.client import Dispatch
>
>     except ImportError as e:
>
>          print e
>
>          sys.exit(1)
>
>       
>
>     if __name__ == '__main__':
>
>          data_source = "C:\\temp\\Database1.accdb"
>
>          access = Dispatch('ADODB.Connection')
>
>          access.Open('PROVIDER=Microsoft.ACE.OLEDB.12.0;Driver={Microsoft
>
>     Access Driver (*.mdb, *.accdb)};DBQ=C:\\temp\\Database1.accdb;')
>
>       
>
>       
>
>     Error:
>
>       
>
>     C:\> a_db.py
>
>     Traceback (most recent call last):
>
>     File "D:\Data\Python Scripts\For the heck of sharepoint\a_db.py", line
>
>     11, in <module>
>
>     access.Open('PROVIDER=Microsoft.ACE.OLEDB.12.0;Driver={Microsoft Access
>
>     Driver (*.mdb, *.accdb)}
>
>     ;DBQ=C:\\temp\\Database1.accdb;')
>
>     File "<COMObject ADODB.Connection>", line 3, in Open
>
>     File "C:\ActivePython27\lib\site-packages\win32com\client\dynamic.py",
>
>     line 276, in _ApplyTypes_
>
>     result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType,
>
>     argTypes) + args)
>
>     pywintypes.com_error: (-2147352567, 'Exception occurred.', (0,
>
>     u'ADODB.Connection', u'Provider canno
>
>     t be found. It may not be properly installed.',
>
>     u'C:\\Windows\\HELP\\ADO270.CHM', 1240655, -21468245
>
>     82), None)
>
>       
>
>       
>
>     ------------------------------
>
>       
>
>     _______________________________________________
>
>     python-win32 mailing list
>
>     python-win32 at python.org  <mailto:python-win32 at python.org>
>
>     http://mail.python.org/mailman/listinfo/python-win32
>
>       
>
>       
>
>     End of python-win32 Digest, Vol 113, Issue 12
>
>     *********************************************
>
>       
>
>       
>
>
>
> We value your opinion. Please take a few minutes to share your 
> comments on the service you received from the District by clicking on 
> this link 
> <http://my.sfwmd.gov/portal/page/portal/pg_grp_surveysystem/survey%20ext?pid=1653>. 




More information about the python-win32 mailing list