Re: How to send multiple SQL commands from Python?

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to send multiple SQL commands from Python?
Date: 2009-10-10 20:53:26
Message-ID: alpine.LNX.2.00.0910101352270.8395@salmo.appl-ecosys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill Todd 2009-10-10 20:57:50 Cannot upgrade to 8.4.1 on Windows
Previous Message Kynn Jones 2009-10-10 20:24:05 Re: How to send multiple SQL commands from Python?