diff --git a/asl_cards/db.py b/asl_cards/db.py index 8f953fb..8d3b88f 100644 --- a/asl_cards/db.py +++ b/asl_cards/db.py @@ -86,6 +86,14 @@ def open_database( fname , create ) : # yup - make it so DbBase.metadata.create_all( db_engine ) +def close_database() : + """Close the database""" + global db_engine , db_session + db_session.close() + db_session = None + db_engine.dispose() + db_engine = None + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - def add_cards( cards ) : diff --git a/startup_widget.py b/startup_widget.py index 42ed1d1..0b584e5 100644 --- a/startup_widget.py +++ b/startup_widget.py @@ -63,6 +63,8 @@ class AnalyzeThread( QThread ) : else : # notify slots that we've finished self.completed_signal.emit( "" ) + finally : + db.close_database() def on_error( self , msg ) : """Show the user an error message."""