psqlodbc connection failes with Python 3.7 (32 bit), worked with python 2.7 32 bit

Viewed 66

We still used Python 2.7 until now and now I am migrating our scripts to Python 3.7. Both Pythonversions are 32 bit. We use a odbc connection to a psqlodbc driver and it workes for my Python 2.7 installation but does not work for my Python 3.7.

Unfortunately my error is in german but it basically sais that it cannot find the procedure and therefore not load the driver:

dbi.opError: Aufgrund des Systemfehlers   127: Die angegebene Prozedur wurde nicht gefunden. (PostgreSQL ANSI, C:\Program Files (x86)\psqlODBC\1300\bin\psqlodbc30a.dll) konnte der angegebene Treiber nicht geladen werden. in LOGIN

This is my code which works for python 2.7 (I changed some company info to ***)

import odbc

constr = (
    "DRIVER={PostgreSQL ANSI};"
    "SERVER=sr05789.sr.***.ch;"
    "PORT=5432;"
    "DATABASE=tcd;"
    "UID=***;"
    "PWD=***;"
    )

con = odbc.odbc(constr)
cur = con.cursor()

I also tried with pyodbc but same story. Where can the problem be here? It's the same code and the same notebook. The only difference is the version of Python (but as mentioned both are 32 bit).

1 Answers

I solved it myself but still don't understand why:)

So the solution was installing another Python 32bit version. I took Python 3.9.6 and now it works.

(First I uninstalled and installed my Python 3.7 again but that didn't help)

Related