Issue 180: Could not connect to PostgreSQL via ODBC under Windows 7
Status:  NoFix
Owner: ----
Closed:  Sep 2012
Reported by jan.p...@gmail.com, May 29, 2011
What steps will reproduce the problem?
1. connstr = 'Driver={PostgreSQL Unicode};Server=192.168.1.1;Port=5432;Database=projekt;Uid=user;Pwd=password'
2. dbconn = pyodbc.connect(self.connstr)
3.

What is the expected output? What do you see instead?
Should establish connection.
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnectW)')

What version of the product are you using? On what operating system?
Windows 7 Ultimate x64. In both ODBC (x32 and x64) PostgreSQL Unicode driver is installed but python should probably use x32 version
Driver C:\Program Files (x86)\psqlODBC\0900\bin\psqlodbc35w.dll
Version 03.51

Please provide any additional information below.


Jun 12, 2011
Project Member #1 mkleehammer
Generally the error means that the the driver name "PostgreSQL Unicode" is not an exact match for an installed driver.  Check the list of drivers install in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers and make sure it is exactly the same.

Status: Investigating
Sep 26, 2012
#2 eatmeima...@gmail.com
This has been a while, but thought I would chime in.  You do not need an ODBC setup on the local machine to connect with PSYCOPG2.
PSYCOPG2 Example connecting to PostgreSQL:

[code]
import psycopg2
pconn_string = "host='gothim' dbname='batlayer' user='batman' password='vickyvale'"
try:
    pconn = psycopg2.connect(pconn_string)
except:
    sys.exit("Unable to connect to PostgreSQL database")
cursor = pconn.cursor()
[/code] 

I don't setup anything in ODBC and don't even have the native drivers or postgresql drivers installed. Works fine, takes two seconds to install psycopg2.  
Sep 29, 2012
Project Member #3 mkleehammer
Closing due to inactivity and inability to reproduce.

Status: NoFix
May 8, 2013
#4 dream...@gmail.com
\COPY command of postgresql is giving error "pyodbc.Error: ('HY000', 'HY000? ERROR: syntax error at or near "\\" at character 7;\nError while executing the query (7) (SQLExecDirectW)')" 
Even though I have escape '\' with '\\'

please Help Thanks in advance