mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
explicitly close ResultProxy objects
session.execute() returns a ResultProxy in case you want to see the result of your query. we don't.
This commit is contained in:
parent
140b46875d
commit
c0e588df88
1 changed files with 3 additions and 4 deletions
|
@ -147,7 +147,6 @@ def load(session, tables=[], directory=None, drop_tables=False, verbose=False, s
|
|||
|
||||
table_objs = sqlalchemy.sql.util.sort_tables(table_objs)
|
||||
|
||||
session = session() # get a concrete Session from a ScopedSession
|
||||
engine = session.get_bind()
|
||||
|
||||
# Limit table names to 30 characters for Oracle
|
||||
|
@ -255,7 +254,7 @@ def load(session, tables=[], directory=None, drop_tables=False, verbose=False, s
|
|||
def insert_and_commit():
|
||||
if not new_rows:
|
||||
return
|
||||
session.execute(insert_stmt, new_rows)
|
||||
session.execute(insert_stmt, new_rows).close()
|
||||
session.commit()
|
||||
new_rows[:] = []
|
||||
|
||||
|
@ -327,7 +326,7 @@ def load(session, tables=[], directory=None, drop_tables=False, verbose=False, s
|
|||
|
||||
session.execute(
|
||||
insert_stmt.values(**row_data)
|
||||
)
|
||||
).close()
|
||||
seen_ids.add(row_data['id'])
|
||||
|
||||
session.commit()
|
||||
|
@ -342,7 +341,7 @@ def load(session, tables=[], directory=None, drop_tables=False, verbose=False, s
|
|||
table_obj = translation_class.__table__
|
||||
if table_obj in table_objs:
|
||||
insert_stmt = table_obj.insert()
|
||||
session.execute(insert_stmt, rows)
|
||||
session.execute(insert_stmt, rows).close()
|
||||
session.commit()
|
||||
# We don't have a total, but at least show some increasing number
|
||||
new_row_count += len(rows)
|
||||
|
|
Loading…
Reference in a new issue