Re: How to send multiple SQL commands from Python? - Mailing list pgsql-general

From Rich Shepard
Subject Re: How to send multiple SQL commands from Python?
Date
Msg-id alpine.LNX.2.00.0910101352270.8395@salmo.appl-ecosys.com
Whole thread Raw
In response to Re: How to send multiple SQL commands from Python?  (Adrian Klaver <aklaver@comcast.net>)
List pgsql-general
On Sat, 10 Oct 2009, Adrian Klaver wrote:

> One way
> Using psycopg2
> DSN = "dbname=? user=? port=? host=?"
> con = psycopg2.connection(DSN)
> cur = con.cursor()
> cur.execute(statement1)
> cur.execute(statement2)
> ....
> con.commit()
>
> Another way, not tested, is triple quote entire block above and pass it to
> cur.execute.

   Both work with pysqlite so I imagine they'll work with postgres as well.

Rich

--
Richard B. Shepard, Ph.D.               |  Integrity            Credibility
Applied Ecosystem Services, Inc.        |            Innovation
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863

pgsql-general by date:

Previous
From: Kynn Jones
Date:
Subject: Re: How to send multiple SQL commands from Python?
Next
From: Bill Todd
Date:
Subject: Cannot upgrade to 8.4.1 on Windows