Re: Multiple result sets

From: joe(at)omc-international(dot)com(dot)au
To: "Clodoaldo" <clodoaldo(dot)pinto(dot)neto(at)gmail(dot)com>
Cc: "Adam Rich" <adam(dot)r(at)sbcglobal(dot)net>, "PostgreSQL - General ML" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Multiple result sets
Date: 2008-06-01 22:24:04
Message-ID: 58894.124.168.21.37.1212359044.squirrel@polaris.omc-international.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> I'm not sure i got it. You mean 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()

You will actually need to do this:

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

Hope that helps,

Joe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris 2008-06-02 00:34:56 Re: phpeclipse debugging & setup
Previous Message Adam Rich 2008-06-01 21:19:16 Re: Multiple result sets