Add __enter__ and __exit__ methods for db, table and column classes to make possible nice temporary connection.
from sqllex import SQLite3x
with SQLite3x('/path/database.db') as db:
# creting connection
db.insert(...)
...
# commit and disconnection
with SQLite3x('/path/database.db').connection as conn:
# creting connection
# doing things (idk)
...
# commit and disconnection
with SQLite3x('/path/database.db')['table'] as table:
# creting connection
table.insert(...)
table.select(...)
# commit and disconnection
with SQLite3x('/path/database.db')['table']['column'] as column:
# creting connection
column.find(...)
# commit and disconnection (if necessary)
Add
__enter__
and__exit__
methods for db, table and column classes to make possible nice temporary connection.P.S.: For developers, stackoverflow "Implementing use of 'with object as o' in custom class in python"