Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > pyodbc problem

Reply
Thread Tools

pyodbc problem

 
 
Martin Gregorie
Guest
Posts: n/a
 
      07-27-2010
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 )


--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: pyodbc - problem passing None as parameter Tim Golden Python 0 10-22-2009 03:02 PM
pyodbc - problem passing None as parameter Frank Millman Python 0 10-22-2009 02:01 PM
Problem with pyodbc, Python? john.goodleaf Python 0 07-31-2008 11:23 PM
Database Access using pyodbc. I've a problem Rajendran Python 3 06-17-2007 10:09 PM
pyodbc data corruption problem Joe Salmeri Python 3 05-24-2007 05:49 PM



Advertisments