CapraLab / pdbmap

3 stars 1 forks source link

Localize SQL calls to a class that automatically opens/closes based on global configuration #13

Closed ChrisMoth closed 3 years ago

ChrisMoth commented 4 years ago

Any pdbmap client class can now: with PDBMapSQLdb() as db: db.this_or_that()

and know that the connection is closed on exit from the block.

Alternately, you bracket the above with: PDBMapSQLdb.open_global_connection() .... PDBMapSQLdb.close_global_connection()

and the connection will stay open across many with.. as type calls.