anthony-tuininga / ceODBC

Python module for accessing databases using the ODBC API.
https://anthony-tuininga.github.io/ceODBC/
12 stars 8 forks source link

Compatibility with requests #6

Closed bschwab003 closed 5 years ago

bschwab003 commented 5 years ago

Is there a compatibility issue with the requests module from PyPi (pip install requests)?

The following works fine....

import ceODBC
print(ceODBC.version)
conn = ceODBC.connect('Driver={MySQL ODBC 8.0 Unicode Driver};Server=127.0.0.1;Database=sys;UID=root;PORT=3306;PWD=u2xWrpQhiCiv3GYLHp2LbfdzNp9g;')
print(conn)

Output:

2.0.1
<ceODBC.Connection to DRIVER={MySQL ODBC 8.0 Unicode Driver};UID=root;PWD=;Server=127.0.0.1;Database=sys;PORT=3306;>

However, the following code hangs on the line establishing the connection. No errors or responses, ever. It just sits.

import requests
print(requests.__version__)
import ceODBC
print(ceODBC.version)
conn = ceODBC.connect('Driver={MySQL ODBC 8.0 Unicode Driver};Server=127.0.0.1;Database=sys;UID=root;PORT=3306;PWD=u2xWrpQhiCiv3GYLHp2LbfdzNp9g;')
print(conn)

Output:

The following prints before it just hangs and never responds.

2.21.0 2.0.1

anthony-tuininga commented 5 years ago

I just tried this myself and I didn't get a hang. Now I wasn't using MySQL ODBC 8.0 Unicode Driver but a PostgreSQL driver. Can you see if it is driver specific?

bschwab003 commented 5 years ago

I just tried again using My ODBC 5.3 Unicode Driver (version 5.03.08.00 to be exact). This time I received the following error which I think is an improvement over the previous behavior.

ceODBC.DatabaseError: [MySQL][ODBC 5.3(w) Driver]Authentication plugin 'caching_sha2_password' cannot be loaded: The specified module could not be found.

But I believe this is a server-side configuration/issue so perhaps this is, in fact, a 8.0-specific issue.

anthony-tuininga commented 5 years ago

So not specific to ceODBC. But why importing the requests module causes problems is a good question. Perhaps requests loads another module first that interferes in some fashion? Hope you can figure it out! Once you do, please update this issue for future readers. Thanks!

bschwab003 commented 5 years ago

I can confirm I can connect with My ODBC 5.3 Unicode Driver (version 5.03.08.00 to be exact) once I created an account that uses standard authentication. In MySQL 8.0, caching_sha2_password is the default authentication plugin rather than mysql_native_password.

2.21.0
2.0.1
<ceODBC.Connection to DRIVER={MySQL ODBC 5.3 Unicode Driver};UID=<removed>;PWD=;Server=127.0.0.1;Database=sys;PORT=3306;>

Not sure at this point what it is about the My ODBC 8.0 Unicode Driver that interferes with the requests module but everything works fine when I either use the older driver or use the 8.0 Driver but import requests AFTER I establish the ceODBC connection. If I find out why this, I will report back.

Thanks as always.