google-code-export / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
1 stars 0 forks source link

Could not connect to PostgreSQL via ODBC under Windows 7 #180

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by jan.p...@gmail.com on 29 May 2011 at 6:18

GoogleCodeExporter commented 9 years ago
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.

Original comment by mkleehammer on 12 Jun 2011 at 5:17

GoogleCodeExporter commented 9 years ago
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.  

Original comment by eatmeima...@gmail.com on 27 Sep 2012 at 1:45

GoogleCodeExporter commented 9 years ago
Closing due to inactivity and inability to reproduce.

Original comment by mkleehammer on 29 Sep 2012 at 7:55

GoogleCodeExporter commented 9 years ago
\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 

Original comment by dream...@gmail.com on 9 May 2013 at 4:14