Python 3 64-bit, connect to 32odbc connection? - python

I want to use spyder console and use odbc connection to get some data.
However I only have the odbc available in 32 bit.
Is there anyway to connect to odbc32 via python 3 64 bit? Upgrading the odbc to 64 bit is not possible.
I currently use pyodbc to connect, ever since I went to spyder 64 bit this doesnt work.
con = pyodbc.connect(r'DSN='+'Stack',autocommit=True)
Error:
Error: ('IM014', '[IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application (0) (SQLDriverConnect)')

Is there anyway to connect to odbc32 via python 3 64 bit?
No.

Related

PYODBC ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')

This is an overused topic of discussion but the waters are still unclear. I have developed a program that uses pyodbc to connect to a .mdb file, it successfully works when I use the 32-bit version of Python and only if on the consrtuctor string write the following constr = "DRIVER={{Microsoft Access Driver (*.mdb)}};Dbq={};".format(dbname) so I naturally thought it was a mismatch between 32bit access and 64bit Python.
However when I tried to make a simple test:
import pyodbc
conn=pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *accdb)};DBQ=C:\Users\emate\OneDrive\Desktop\pyodbctest\Database2.accdb;')
cursor=conn.cursor()
cursor.execute('SELECT * FROM Table1')
for row in cursor.fetchall():
print(row)
I ran it and got the same error. The problem is I checked the Office Version and says it is 64bit,python is also 64bit so if it is not a mismatch problem then what is this problem?
I want to run the program on a raspberrypi microcomputer (64bit) and it is tremendously hard to use a 32bit version on it to just run the program.

How should I configure the a connection to MS Azure cloud database using pyodbc?

I'm setting up a python script to connect to an instance of the azure cloud database, and seeing a difference in the connection when I use IDLE vs when I try to execute the connection from a script. For example, when I do the following in IDLE:
>>> import pyodbc
>>> conn = pyodbc.connect('DRIVER={SQL Server};SERVER=<my.database.host.info>,1433', user='<my_username#mydatabase', password='password', database='database')
I'm able connect successfully and execute a basic query against one of the tables in the database.
However when I use the same connection string (copied from the IDLE console) in a script, I get the following error:
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
Usually, the issue is raised because the 32/64 bit version of python environment and odbc driver are mismatched.
You may check the python version and odbc driver version you used to run the script. You have to manage to change both of them need to be 32-bit (or both 64-bit) in order for this to work.
You can get the specified version of pyodbc extension from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyodbc.

"Data source name not found and no default driver specified" with Access ODBC

My Softwares:
Python 3.4 -64 bit
PyODBC 64 bit
MS office package Installed (32 bit)
Problem:
Now, I try to access MS Access 2010 installed in my computer using PYODBC. It does not work regardless of what I try. My error is always this:
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
I already looked at:
pyodbc and ms access 2010 connection error
Cannot connect to Access DB using pyodbc
It is suggested that it is 32-64 bit problem which I am sure it is. Is there some modification that can be done to make it work without installing 32 bit python and 32 bit pyodbc? I checked this website.Using ODBC (32-bit and 64-bit) on 64-bit Windows which explains about accessing the control panel to modify ODBC connnection and/or drivers. However, I don't know much about windows database connection internals to commence some changes.
Is there something that I can do to make it work?
Is there some modification that can be done to make it work without installing 32 bit python and 32 bit pyodbc?
Not really. If you have 32-bit Office installed then you have the 32-bit version of the Access Database Engine (a.k.a. "ACE"), and only 32-bit applications can use it.
The installer for the 64-bit version of the Access Database Engine will abort if it detects 32-bit Office components. There is a way to force the installer to continue, but that is not recommended because it can apparently break Office.
Bottom Line: The "bitness" of your application must match the "bitness" of the installed Access Database Engine. So, practically speaking, your options are
Use 32-bit Python and pyodbc, or
replace your 32-bit Office with the 64-bit version.

Python-Oracle connection issue with Pyodbc

Tried to connect to the Oracle database using Pyodbc:
try:
db_connection = pyodbc.connect('DSN=OraDev; PWD=%s' % Key.dbKeys['password'])
except pyodbc.Error, err:
print >> debug_file, "Database connection failed: %s" %err
sys.exit()
and it keeps giving me this error message:
'[IM014] [Microsoft][ODBC Driver Manager] The specified DSN
contains an architecture mismatch between the Driver and Application
(0) (SQLDriverConnect)
So I am wondering if the culprit is that I am not having the "matching" components. Currently, I have:
Python 2.7 32bit
Pyodbc 3.0.6 win32-py2.7
Oracle ODBC driver: 32bit
Windows server 2008 64bit
Oracle 11.2.0 64bit
Are there anything wrong with the versions here? Thanks.
The issue you are having is that 64 bit Windows does not play well with 32 bit ODBC. You can read more about it here:
The 32-bit version of the ODBC Administrator tool and the 64-bit version of the ODBC Administrator tool display both the 32-bit user DSNs and the 64-bit user DSNs in a 64-bit version of the Windows operating system.
The work around is to specifically target the ODBC driver for the architecture you are looking to implement.
A side note, trying to implement ODBC for oracle on a mixed architecture platform became a headache for us. So, we implemented access to oracle through CX_Oracle

Connecting to MS Access 2007 (.accdb) database using pyodbc

I am on Win7 x64, using Python 2.7.1 x64. I am porting an application I created in VC++ to Python for educational purpouses.
The original application has no problem connecting to the MS Access 2007 format DB file by using the following connection string:
OleDbConnection^ conn = gcnew OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=|DataDirectory|DB.accdb");
Now, when I try to connect to the same DB file (put in C:\ this time) in Python using pyodbc and the following conenction string:
conn = pyodbc.connect("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\DB.accdb;")
, and no matter whether I keep the OLEDB provider or I use the Provider=MSDASQL; as mentioned here (MS mentions it's not availiable for 64bit), I keep getting the following error:
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnectW)')
What might cause this problem?
ADD:
I have looked into pyodbc docs more closely and tried conn = pyodbc.connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=c:\\DB.accdb;") - the same error. This is really weird, since the pyodbc.dataSources() shows that I have this provider.
ADD2:
I tried win32com.client usage such as here in order to connect by using OLE DB - no success. Seems that it's impossible, nothing works.
Try to use something like the following instead of using the same string as the one for OLeDb:
"Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\DB.accdb;"
You may not be able to talk to the driver directly from your x64 Python application: Access 2007 and its ACE driver are 32 bits only.
Instead, get the ACE x64 driver for Access 2010, but be careful that if you already have Access or the ACE driver 32bit installed, it won't work.
I would stick to the 32bit versions of Python and of the ACE driver if you expect your app to be run on other systems: it is not recommended to mix x64 and x86 versions of Office tools and drivers, you'll probably end up with lots of issues if you do.
If the issue is not with the 32/64bit mix, then maybe this question has the answer you seek.

Categories

Resources