On 1 Oct 2001 11:48:31 -0700, rdack <rdacker(at)pacbell(dot)net> wrote:
>from python using PgSQL.
>i get:
>" libpq.OperationalError: ERROR: CREATE DATABASE: may not be called
>in a transaction block"
>
>in a python script i do :
>db = PgSQL.connect(database='template1')
>cur=db.cursor()
>cur.execute("create database tt2")
>cur.close()
>del db, cur
>
>how does one not be in a transaction block?
>what is the correct way to create a db?
Turn on autocommit. For example:
db = PgSQL.connect(database='template1')
db.autocommit = 1 # You must turn on autocommit before creating any cursor.
cur = db.cursor()
cur.execute("create database tt2")
cur.close()
del db, cur
--
____ | Billy G. Allie | Domain....: Bill(dot)Allie(at)mug(dot)org
| /| | 7436 Hartwell | MSN.......: B_G_Allie(at)email(dot)msn(dot)com
|-/-|----- | Dearborn, MI 48126|
|/ |LLIE | (313) 582-1540 |