Hi,
Sometimes the following code let cursor.execute() run in the "Cannot operate on a closed cursor" issue (seen with Trac 1.0 and SQLite). I played around with several trials for a fix but nothing seems to help. Could you help me and correct the following code example so that I can see what the proper use of that db API is? Yes, I’ve read http://trac.edgewall.org/wiki/TracDev/DatabaseApi but it’s still not clear to me how I must fix the closed cursor error. Thanks in advance.
class SmpModel(Component):
# DB Method
def __get_cursor(self):
if VERSION < '0.12':
self.db = self.env.get_db_cnx()
else:
self.db = self.env.get_read_db()
return self.db.cursor()
def __start_transacction(self):
if VERSION < '0.12':
# deprecated in newer versions
self.db.commit()
self.db.close()
def get_ticket_project(self, id):
cursor = self.__get_cursor()
query = """SELECT
value
FROM
ticket_custom
WHERE
name = 'project' AND ticket = %s"""
cursor.execute(query, [id])
self.__start_transacction()
return cursor.fetchone()
CU, F@lk
----
R&D Software
Baumer Optronic GmbH
Hi,
Sometimes the following code let cursor.execute() run in the "Cannot operate on a closed cursor" issue (seen with Trac 1.0 and SQLite). I played around with several trials for a fix but nothing seems to help. Could you help me and correct the following code example so that I can see what the proper use of that db API is? Yes, I’ve read http://trac.edgewall.org/wiki/TracDev/DatabaseApi but it’s still not clear to me ... snip