OCBC connection

Steve Holden steve at holdenweb.com
Fri Sep 28 16:04:00 EDT 2007


kyosohma at gmail.com wrote:
[...]
>>
>>  >>> curs = conn.cursor()
>>  >>> import psycopg2 as db
>>  >>> conn = db.connect(database="pycon", user="username",
>>          password="password", host="localhost", port=5432)
>>  >>> curs = conn.cursor()
>>  >>> curs.execute("SELECT orgid, orgname FROM organization")
>>  >>> from pprint import pprint # just for neatness
>>  >>> pprint(curs.fetchall())
>> [(1, 'AB Strakt'),
>>   (79, 'DevIS'),
>>      ...
>>   (113, 'Test Organization'),
>>   (19, 'Holden Web LLC')]
>>  >>>

> Whoops! I almost posted some code using the adodb or the odbc module,
> which is what I would have probably used, but I figured I'd take a
> look and see if there was a postgres module available. I'm not seeing
> any basic differences between your code and the code I linked to
> though...except that if I ran your first line of code, I would get an
> exception as "conn" hasn't been defined yet.
> 
> Whatever. I apologize for being misleading(?)
> 
I screwed up anyway - the first line shouldn't have been included.

But perhaps Sean could enlighten us as to whether ODBC is really a 
requirement, or simply the first solution that he thought of. I don't 
know why one would *require* ODBC.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline




More information about the Python-list mailing list