From c0d7eb4df80044d758a20e3211f4bc437d3d1186 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Mon, 12 Feb 2007 18:41:27 +0000 Subject: [PATCH] - close cursors after use --- PLC/PostgreSQL.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PLC/PostgreSQL.py b/PLC/PostgreSQL.py index f15ebf9c..d996e722 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.13 2007/02/11 04:53:40 mlhuang Exp $ +# $Id: PostgreSQL.py,v 1.14 2007/02/11 18:34:06 mlhuang Exp $ # import psycopg2 @@ -130,7 +130,8 @@ class PostgreSQL: self.connection.rollback() def do(self, query, params = None): - self.execute(query, params) + cursor = self.execute(query, params) + cursor.close() return self.rowcount def last_insert_id(self, table_name, primary_key): @@ -194,7 +195,9 @@ class PostgreSQL: to the query. """ - rows = self.execute(query, params).fetchall() + cursor = self.execute(query, params) + rows = cursor.fetchall() + cursor.close() if hashref or key_field is not None: # Return each row as a dictionary keyed on field name -- 2.47.0