The Python DB-API (2.0) specifies that on creation a connection object is to start a transaction if the database supports them. The pgdb implementation of the DB-API does this:
>>> Begin Listing 1
class pgdbCnx:
def __init__(self, cnx):
self.__cnx = cnx
self.__cache = pgdbTypeCache(cnx)
try:
src = self.__cnx.source()
src.execute("BEGIN")
except:
raise OperationalError, "invalid connection."
>>> End Listing 1
This is all well and good except there does not seem to be any way of NOT starting a transaction block. This is a real problem if you are trying to create admin scripts that automate database creation as CREATE DATABASE in PostgreSQL can not be called from within a transaction block. Listing 2 shows the raw SQL typed into psql that simulates what happens from the pgdb module when you try and create a database:
>>> Begin Listing 2
cedward1=# begin;
BEGIN
cedward1=# create database thingy;
ERROR: CREATE DATABASE: may not be called in a transaction block
>>> End Listing 2
I'll let the experts argue as to whether this is a problem for Python's DB-API or a PostgreSQL issue.
Carwyn
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly