Transaction persistence between execute() calls

Clodoaldo <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
I need that 5 queries fired by the same ajax request to a web python
application see the same database snapshot and i don't understand how
exactly to do it. Could it be like this:?

import psycopg2 as db
dsn = 'host=localhost dbname=dbname user=user password=passwd'
connection = db.connect(dsn)
cursor = connection.cursor()

cursor.execute('BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;');
rs1 = cursor.execute(query_1, (param1,))
rs2 = cursor.execute(query_2, (param2,))
cursor.execute('COMMIT;');

cursor.close()
connection.close()

Or:

cursor.execute('BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;');
rs1 = cursor.execute(query_1, (param1,))
rs2 = cursor.execute(query_2, (param2,))

cursor.close()
connection.commit()
connection.close()

Or something else? BTW i can't find the html doc with all the classes.
Where is it?

Regards, Clodoaldo Pinto Neto
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.