Connecting to PostgreSQL using pyodbc

PostgreSQL works for me on localhost. I have the psqlODBC driver installed. Now when I try to connect to the server using pyodbc like:

import pyodbc
connection = pyodbc.connect("DRIVER={psqlOBDC};SERVER=localhost;DATABASE=weather;UID=postgres;PWD=password")

but I get this error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyodbc.Error: ('08001', '[08001] Already connected. (202) (SQLDriverConnect)')

What is the problem?

Thank.

+3
source share
1 answer

Of course, you must install the ODBC driver. I don’t know a Mac, but on Windows there is an ODBC Manager where you set up Data Sources. There is a Test button for the PostgreSQL driver to check if it is possible to establish a connection.

, PostgreSQL. Jython, JDBC-. , psycopg, PyGreSQL pg8000 ( Python). ?

+3

All Articles