Re: Re: "create database" not allowed within transaction

Andrew McNamara <[email protected]> Wed, 20 Apr 2005 13:51:13 +1000
Newsgroups gmane.comp.python.db.pypgsql.user
Message-ID <[email protected]>
>> If I attempt to:
>>    cursor.execute('create database blah...')
>> I get the following error:
>>    libpq OperationalError:  ERROR: CREATE DATABASE cannot run inside a 
>> transaction block
>>
>> How can I accomplish my objective?
>
>Here's one way to do it, though kludgey:
>    cursor.execute('commit') # note that this closes our transaction, so 
>that the following works:
>    cursor.execute('create database blah')

The method I use is:

    db = PgSQL.connect(...)
    db.autocommit = True
    curs = db.cursor()
    curs.execute('....')
    db.close()

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/


-------------------------------------------------------
This SF.Net email is sponsored by: New Crystal Reports XI.
Version 11 adds new functionality designed to reduce time involved in
creating, integrating, and deploying reporting solutions. Free runtime info,
new features, or free trial, at: http://www.businessobjects.com/devxi/728