From 1fe6f5d6d78c4e6f55820614b54be6562265ffa3 Mon Sep 17 00:00:00 2001 From: Andrew Browning Date: Mon, 22 Feb 2016 19:15:40 -0500 Subject: [PATCH] Fix issue #5411 sqlite connection closes This update changes migrations to wrap db.execute results in a list to keep the connection from closing for sqlite migrations. --- .../versions/101510e3a713_removes_graveyard_items_from_.py | 3 ++- .../versions/8429e33fdf7_remove_the_graveyard_objects_from_.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mediagoblin/db/migrations/versions/101510e3a713_removes_graveyard_items_from_.py b/mediagoblin/db/migrations/versions/101510e3a713_removes_graveyard_items_from_.py index 800e0448..723100c5 100644 --- a/mediagoblin/db/migrations/versions/101510e3a713_removes_graveyard_items_from_.py +++ b/mediagoblin/db/migrations/versions/101510e3a713_removes_graveyard_items_from_.py @@ -32,7 +32,8 @@ def upgrade(): collection_items_table = inspect_table(metadata, "core__collection_items") graveyard_table = inspect_table(metadata, "core__graveyard") - for tombstone in db.execute(graveyard_table.select()): + res = list(db.execute(graveyard_table.select())) + for tombstone in res: # Get GMR for tombstone gmr = db.execute(gmr_table.select().where(and_( gmr_table.c.obj_pk == tombstone.id, diff --git a/mediagoblin/db/migrations/versions/8429e33fdf7_remove_the_graveyard_objects_from_.py b/mediagoblin/db/migrations/versions/8429e33fdf7_remove_the_graveyard_objects_from_.py index 8f222a6a..978260df 100644 --- a/mediagoblin/db/migrations/versions/8429e33fdf7_remove_the_graveyard_objects_from_.py +++ b/mediagoblin/db/migrations/versions/8429e33fdf7_remove_the_graveyard_objects_from_.py @@ -28,7 +28,8 @@ def upgrade(): graveyard_table = inspect_table(metadata, "core__graveyard") gmr_table = inspect_table(metadata, "core__generic_model_reference") - for tombstone in db.execute(gmr_table.select()): + res = list(db.execute(gmr_table.select())) + for tombstone in res: # Look up the gmr for the tombstone8 gmr = db.execute(gmr_table.select().where(and_( gmr_table.c.obj_pk == tombstone.id, -- 2.25.1