kopia lustrzana https://github.com/micropython/micropython-lib
unix-ffi/sqlite3: Fix statements not being finalized.
Currently, statements are only finalized upon a call to Cursor.close(). However, in Cursor.execute() new statements get created without the previous statements being finalized, causing those to get leaked, preventing the database from being closed. The fix addresses this by finalizing the previous statement if it exists. Signed-off-by: Robert Klink <rhermanklink@ripe.net>pull/905/head
rodzic
8d6ebf57a2
commit
0a65c3d34a
|
@ -84,6 +84,11 @@ class Cursor:
|
|||
self.stmnt = None
|
||||
|
||||
def execute(self, sql, params=None):
|
||||
if self.stmnt:
|
||||
# If there is an existing statement, finalize that to free it
|
||||
res = sqlite3_finalize(self.stmnt)
|
||||
check_error(self.h, res)
|
||||
|
||||
if params:
|
||||
params = [quote(v) for v in params]
|
||||
sql = sql % tuple(params)
|
||||
|
|
Ładowanie…
Reference in New Issue