pyodbc problem

M

Martin Gregorie

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@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@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 )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top