| From: | bga(at)bajor(dot)mug(dot)org (Billy G(dot) Allie) |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: pypgsql 'create database' problem |
| Date: | 2001-10-05 16:20:58 |
| Message-ID: | slrn9rrnbb.627.bga@bajor.mug.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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 |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Gershon M. Wolfe | 2001-10-05 17:49:20 | pg_noname.8204 |
| Previous Message | Jeff Boes | 2001-10-05 16:18:33 | Broken FAQ link |