Re: pypgsql 'create database' problem

From: rdacker(at)pacbell(dot)net (rdack)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: pypgsql 'create database' problem
Date: 2001-10-02 20:29:07
Message-ID: 644f6688.0110021229.556c232c@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

rdacker(at)pacbell(dot)net (rdack) wrote in message news:<644f6688(dot)0110011048(dot)51982136(at)posting(dot)google(dot)com>...
> 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?

answer is to use libpq module. low level interface has method to
execute queries without wrapping in a transaction:

import libpq
db = libpq.PQconnectdb('dbname=%s' % db_name)
db.query('create database %s' % tbl_name)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mayan 2001-10-02 20:29:22 Re: Connection to database 'template1' failed.
Previous Message Maxim 2001-10-02 19:17:17 Function multiple results returns