DSN=MyPostgresDB;UID=myuser;PWD=mypass;
DRIVER=PostgreSQL Unicode;SERVER=localhost;DATABASE=mydb;UID=myuser;PWD=mypass;PORT=5432; odbc postgres
[PostgreSQL Unicode] Description = PostgreSQL ODBC driver Driver = /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so Driver64 = /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so Setup64 = /usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so Using isql (UnixODBC) isql MyPostgresDB myuser mypass -v Run a test query: odbc postgres
[MyPostgresDB] Driver = PostgreSQL Unicode Server = localhost Port = 5432 Database = mydb Username = myuser Password = mypass SSLmode = require Also check /etc/odbcinst.ini (driver definition): odbc postgres
SELECT version(); import pyodbc conn_str = ( "DRIVER=PostgreSQL Unicode;" "SERVER=localhost;" "PORT=5432;" "DATABASE=mydb;" "UID=myuser;" "PWD=mypass;" ) conn = pyodbc.connect(conn_str) cursor = conn.cursor() cursor.execute("SELECT 1") print(cursor.fetchone()) 5. Common Connection String Formats Generic ODBC: