pg.ddx.io pgsql-admin@postgresql.org mailing list archivehelp / color / mirror / Atom feed
using pgdb and python 2+ messages / 2 participants [nested] [flat]
* using pgdb and python @ 2005-12-08 22:27 David Bear <David.Bear@asu.edu> 2005-12-08 23:25 ` Re: using pgdb and python Joshua D. Drake <jd@commandprompt.com> 0 siblings, 1 reply; 2+ messages in thread From: David Bear @ 2005-12-08 22:27 UTC (permalink / raw) To: pgsql-admin I am using python to collect data and insert it into postgresql. I am hoping there will be someone on this list that has used python for this becuase all the books and documentation on the subject seem sparse. I am using pgdb. I know psycpg is also a DBI compliant interface for postgresql. If there is a recommendation as to which one is better, I'd like to hear it. (better for me now means that it has better documentation, sample code, etc.) I am constructing a sql insert statement (parameterized) and would like to catch meaningfull exceptions like, keyviolation (on the insert) or other postgresql exceptions that might happen. So far the only exception I see from pgdb when I do a full traceback and anlyze that. What I would like is something like try: cursor.execute(sql, parameters) except KeyViolation: except DataConversionError: and such like. I would really appreciate any pointers you might have on using python with postgresql. thanks. -- David Bear phone: 480-965-8257 fax: 480-965-9189 College of Public Programs/ASU Wilson Hall 232 Tempe, AZ 85287-0803 "Beware the IP portfolio, everyone will be suspect of trespassing" ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: using pgdb and python 2005-12-08 22:27 using pgdb and python David Bear <David.Bear@asu.edu> @ 2005-12-08 23:25 ` Joshua D. Drake <jd@commandprompt.com> 0 siblings, 0 replies; 2+ messages in thread From: Joshua D. Drake @ 2005-12-08 23:25 UTC (permalink / raw) To: David.Bear@asu.edu; +Cc: pgsql-admin > I am using pgdb. I know psycpg is also a DBI compliant interface for > postgresql. If there is a recommendation as to which one is better, > I'd like to hear it. (better for me now means that it has better > documentation, sample code, etc.) I know nothing of pgdb but Command Prompt uses psycopg exclusively and it works very well. > > I am constructing a sql insert statement (parameterized) and would > like to catch meaningfull exceptions like, keyviolation (on the > insert) or other postgresql exceptions that might happen. So far the > only exception I see from pgdb when I do a full traceback and anlyze > that. What I would like is something like > > try: > cursor.execute(sql, parameters) > except KeyViolation: > > except DataConversionError: > > and such like. > > I would really appreciate any pointers you might have on using python > with postgresql. I would look at psycopg and specifically psycopg2. Joshua D. Drake > > thanks. > -- The PostgreSQL Company - Command Prompt, Inc. 1.503.667.4564 PostgreSQL Replication, Consulting, Custom Development, 24x7 support Managed Services, Shared and Dedicated Hosting Co-Authors: PLphp, PLperl, ODBCng - http://www.commandprompt.com/ ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2005-12-08 23:25 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2005-12-08 22:27 using pgdb and python David Bear <David.Bear@asu.edu> 2005-12-08 23:25 ` Joshua D. Drake <jd@commandprompt.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox