OCBC connection
Sugrue, Sean
Sean.Sugrue at analog.com
Fri Sep 28 16:46:24 EDT 2007
I want to connect on the windows side to a solaris server which has a
postgres database installed.
I can connect to the postgres database using the postgres odbc
connection but I'm using excel.
I'd rather use python because it ports easily over to solaris. I will
install psycopg2 and try the code
that was sent.
Thanks
Sean
-----Original Message-----
From: python-list-bounces+sean.sugrue=analog.com at python.org
[mailto:python-list-bounces+sean.sugrue=analog.com at python.org] On Behalf
Of Steve Holden
Sent: Friday, September 28, 2007 4:04 PM
To: python-list at python.org
Subject: Re: OCBC connection
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
--
http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list