Search Postgresql Archives

Re: How to send multiple SQL commands from Python?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux