Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 23rd, 2012, 04:21 AM
SachinS SachinS is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 12 SachinS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 37 m 41 sec
Reputation Power: 0
Access DB 2007

Dear all,
I am facing some problems while accessing the AccessDB 2007 from pythonwin. Could you please help. Or also if you know any other way using win32com to access the access2007 db.

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)

Reply With Quote
  #2  
Old September 12th, 2012, 05:06 PM
Quackajack Quackajack is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 39 Quackajack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 49 m 43 sec
Reputation Power: 1
64bit v 32bit

I believe you are running a 64bit OS and an 64bit build of Python. However the Access 2007 drivers you are using are 32bit (it wasn't until 2010 that they produced a 64bit version).

I happen to have both 32bit and 64bit Python builds installed for testing; the Access database opens fine with the given commands on the 32bit version but not the 64bit.

I've not (yet) been able to work out a solution if you need to use the 64bit build but there is a Microsoft Access Database Engine 2010 Redistributable that has a 64bit version you could try.

Last edited by Quackajack : September 13th, 2012 at 12:44 AM. Reason: Added link

Reply With Quote
  #3  
Old September 13th, 2012, 06:37 AM
SachinS SachinS is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 12 SachinS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 37 m 41 sec
Reputation Power: 0
I left it to Python to work out the reading and updating for me, so the following works with the versions I have and are currently sufficient to get around my work.

Code Snippet:
==========
access = Dispatch('Access.Application')
dbpath = 'myDB.accdb'
print dbpath
dbengine = access.DBEngine
workspace = dbengine.Workspaces(0)
newdb = workspace.OpenDatabase(dbpath)
recordSet = newdb.Recordset('select * from Table1')

while not recordSet.EOF:
print recordSet.Fields('ID').Value
recordSet.MoveNext()

Thanks !
T

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Access DB 2007

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap