473,387 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to get connected to *.mdb with pypyodbc py2.7 win64

I'm working on a script that make consults on mdb files with the module pypyodbc, but when it's time to connect with the file it give me an exception.

Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)] on win32

This is the code:

Expand|Select|Wrap|Line Numbers
  1. def make_consult(fpath, table, column_name, searched_val):
  2. #    Try No. 1
  3.     con = pypyodbc.win_connect_mdb(fpath)
  4. #    Try No. 2
  5. #    connection_string = "Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=%s" %fpath
  6. #    con = pypyodbc.connect(connection_string)
  7.     cur = con.cursor()
  8.     sql = ("""SELECT * FROM """ + table + """ WHERE """ + column_name + """ LIKE '%""" + searched_val + """'%;""")
  9.     rsql = cur.execute(sql)
  10.     rsql = rsql.fetchall()
  11.     cur.close()
  12.     con.close()
  13.     return rsql
  14.  

In both tries I get the same exception:

Expand|Select|Wrap|Line Numbers
  1. Traceback (most recent call last):
  2.   File "<stdin>", line 1, in <module>
  3.   File "C:\Python27\64\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 682, in runfile
  4.     execfile(filename, namespace)
  5.   File "C:\Python27\64\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
  6.     exec(compile(scripttext, filename, 'exec'), glob, loc)
  7.   File "C:/AAA/Extractor de Datos.py", line 46, in <module>
  8.     a = make_consult(p, table_name(p), 'ClaveInst', 'RbRomanza1')
  9.   File "C:/AAA/Extractor de Datos.py", line 35, in make_consult
  10.     con = pypyodbc.connect(connection_string)
  11.   File "build\bdist.win-amd64\egg\pypyodbc.py", line 2434, in __init__
  12.   File "build\bdist.win-amd64\egg\pypyodbc.py", line 2483, in connect
  13.   File "build\bdist.win-amd64\egg\pypyodbc.py", line 988, in check_success
  14.   File "build\bdist.win-amd64\egg\pypyodbc.py", line 964, in ctrl_err
  15. pypyodbc.Error: (u'HY000', u"[HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x10dc Thread 0x5d0 DBC 0x4338008                                                              Jet'.")
  16.  
May 7 '15 #1
1 4735
After a while of looking for how can fix this i think i got it...

On Windows 8.1 64-bits, Python 64-bits, MS Office 32-bits

1. Install AccessDatabaseEngine (because MS Office 32 bits)
https://www.microsoft.com/en-us/down....aspx?id=13255

2. Verify this: Control Panel/Administrative Tools ->
right click on ODBC Data Sources (32-bits) in Target:
%windir%\syswow64\odbcad32.exe
right click on ODBC Data Sources (64-bits) in Target:
%windir%\system32\odbcad32.exe

3. Uninstall Python 64-bits and install Python 32-bits and pypyodbc module

Done...
By the way, in the code above line 8:
(the second '% must be %')
Expand|Select|Wrap|Line Numbers
  1.     sql = ("""SELECT * FROM """ + table + """ WHERE """ + column_name + """ LIKE '%""" + searched_val + """'%;""")
  2.  
Replace by this
Expand|Select|Wrap|Line Numbers
  1.     sql = ("""SELECT * FROM %s WHERE %s LIKE %s;""" %(table, column_name, "'%" + searched_val + "%'"))
  2.  
Hope this help somebody else...
May 7 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mauro Cicognini | last post by:
Hi to everybody, please forgive me if what I'm asking is obvious but I couldn't really find out any good pointers in a few hours of googling on the python site and related places. The question...
0
by: Christian McArdle | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.os.ms-windows.programmer.win64 This is a formal Request For Discussion (RFD) to create comp.os.ms-windows.programmer.win64 as an unmoderated...
0
by: Christian McArdle | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.os.ms-windows.programmer.win64 This is a formal Request For Discussion (RFD) to create comp.os.ms-windows.programmer.win64 as an unmoderated...
0
by: Vijay Chegu | last post by:
Hi I am using vc++ .net 2003 ide with Feb 2003 platform sdk to build 64bit application. I want to use vc++ to debug the app on 64bit machine. As we do not have 64bit VC++, I would like to...
3
by: Dennis Landi | last post by:
Hello, I have three questions: 1) I have been perusing the MSDN VC++ pages. Everything seems to be geared towards .NET integration. Will MS continue support natively compiled code or will...
2
by: Olaf Baeyens | last post by:
Just a silly question: If I understand correctly pure C# compiled as Win32 will run as Win64 without need to recompile. But will pure managed C++ also be able to do that? I also heard that pure...
15
by: Sharon | last post by:
I'm thinking to move from WinXP 32bit to Windows 2003 Server 64 bit. But first I have some unclear issues that would like to clarify in here using your kind help: (1) Can I take a driver (like the...
2
by: Egbert Nierop \(MVP for IIS\) | last post by:
Hello, I created a Win64 build environment by copying from a Win32 environment, and modifying the Win32 macro to the Win64 macro. After that, the properties window does not load anymore and...
3
by: Taras Ovsyankin | last post by:
Hi, We have several 64-bit libraries here built with vc7, AMD64 SDK. I'm wondering if it is OK to link them into vc8 win64 project. What are potential issues? Thank you, Taras
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.