X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 3AE0D9DD5E1 for ; Thu, 8 Dec 2005 19:25:19 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99370-10 for ; Thu, 8 Dec 2005 19:25:21 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by postgresql.org (Postfix) with ESMTP id CC9C59DD59B for ; Thu, 8 Dec 2005 19:25:16 -0400 (AST) Received: from [192.168.1.55] (fc1smp [66.93.38.87]) (authenticated bits=0) by hosting.commandprompt.com (8.13.4/8.13.4) with ESMTP id jB8NGnZS007983; Thu, 8 Dec 2005 15:16:49 -0800 Subject: Re: using pgdb and python From: "Joshua D. Drake" Reply-To: jd@commandprompt.com To: David.Bear@asu.edu Cc: pgsql-admin@postgresql.org In-Reply-To: <20051208222737.GD29823@asu.edu> References: <20051208222737.GD29823@asu.edu> Content-Type: text/plain Organization: Command Prompt, Inc. Date: Thu, 08 Dec 2005 15:25:53 -0800 Message-Id: <1134084353.8592.23.camel@jd.commandprompt.com> Mime-Version: 1.0 X-Mailer: Evolution 2.4.2 (2.4.2-1.1.fc4.nr) Content-Transfer-Encoding: 7bit X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by milter-greylist-1.6 (hosting.commandprompt.com [192.168.1.101]); Thu, 08 Dec 2005 15:16:49 -0800 (PST) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200512/74 X-Sequence-Number: 19794 > 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/