From c4b7fddda7252f72f052010ab8878f2025d9e07f Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Sun, 11 Feb 2007 04:53:40 +0000 Subject: [PATCH] - try obtaining another cursor once if it appears to be closed --- PLC/PostgreSQL.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/PLC/PostgreSQL.py b/PLC/PostgreSQL.py index 495435e..57321f5 100644 --- a/PLC/PostgreSQL.py +++ b/PLC/PostgreSQL.py @@ -5,7 +5,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: PostgreSQL.py,v 1.11 2006/12/04 19:10:47 mlhuang Exp $ +# $Id: PostgreSQL.py,v 1.12 2007/02/08 15:15:21 mlhuang Exp $ # import psycopg2 @@ -153,7 +153,13 @@ class PostgreSQL: if psycopg2: query = re.sub(r'(%\([^)]*\)|%)[df]', r'\1s', query) - cursor.executemany(query, param_seq) + try: + cursor.executemany(query, param_seq) + except InterfaceError: + # Try one more time with another cursor + cursor = self.cursor = self.db.cursor() + cursor.executemany(query, param_seq) + (self.rowcount, self.description, self.lastrowid) = \ (cursor.rowcount, cursor.description, cursor.lastrowid) except Exception, e: -- 2.43.0