Prev: suitable py2app.
Next: Why are String Formatted Queries Considered So Magical? (Spammeranalysis)
From: Martin Gregorie on 27 Jul 2010 14:02 I have a small problem: I can't get pyodbc to connect to a PostgreSQL database. All it does is spit out a malformed error message. When I run this: ============================================== import pyodbc dsn = pyodbc.dataSources() print "Data sources: %s" % dsn conn = pyodbc.connect(dsn="marchive") print "ODBC connection: %s" % conn ============================================== I get this: ============================================== [kiwi(a)zappa python]$ python dsncheck.py Data sources: {'ma': 'PostgreSQL', 'marchive': 'PostgreSQL'} Traceback (most recent call last): File "dsncheck.py", line 6, in <module> conn = pyodbc.connect(dsn="marchive") pyodbc.Error: ('0', '[0] [unixODBC]c (0) (SQLDriverConnectW)') ============================================== so the data source exists and is evidently found by connect(), whiuch seems unable to make sense of it. The pgsql module works well, but I would prefer to use ODBC because its not so closely bound to a single RDBMS. unixODBC, which I understand underlies pyodbc, works OK too: ============================================== [kiwi(a)zappa python]$ isql marchive marchive n/a +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL> select count(*) from address; +---------------------+ | count | +---------------------+ | 32 | +---------------------+ SQLRowCount returns 1 1 rows fetched SQL> quit ============================================== Questions: - Why does pyodbc blow up when its apparently trying to talk to unixODBC? - What does this mean: pyodbc.Error: ('0', '[0] [unixODBC]c (0) (SQLDriverConnectW)') I'm new to Python, though not to Linux, PostgreSQL, ODBC, C or Java. My rig and software: Linux: Fedora 12 Where I'm running Python and ODBC, Lenovo Thinkpad R61i: Core Duo. Fedora 10 Where PostgreSQL is installed, IBM NetVista: Pentium III. PostgreSQL: 8.3.8 Python: 2.6.2 pyodbc 2.1.5-3.fc12 ) By yum from RH repository unixODBC 2.2.14-11.fc12 ) -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
|
Pages: 1 Prev: suitable py2app. Next: Why are String Formatted Queries Considered So Magical? (Spammeranalysis) |