connection

Module: luescher_nd.database.connection

Interface for establishing connection with a database

class DatabaseSession(database, dtype='sqlite', verbose=False, commit=True)[source]

Class which allows intuitve acces to databases interfacing sqlalchemy.

The connection is automatically commited (or rolled back in case of an error) and closed.

__enter__()[source]

Establishes a connection to the database and returns the cursor.

__exit__(typ, value, traceback)[source]

Commits and closes the database session.

If no exception occured, the database is commit. Else the database is rolled back.

__init__(database, dtype='sqlite', verbose=False, commit=True)[source]

Initialize DatabaseConnection for connecting to an sqlite database

Parameters
  • database (str) – The database address.

  • dtype (str) – The type of the databse.

  • verbose (bool) – Return extra output.

  • commit (bool) – Commit database on exit.

__repr__()[source]

Returns descriptive string

__str__()[source]

Returns descriptive string

property connection_string

Returns the connection string {dtype}:///{database}