neuralib.sqlp.cli

class neuralib.sqlp.cli.Database[source]

A class for the common usage of using sqlite.

sqlp_debug_mode = False
abstract property database_file: Path | None

sqlite database filepath

abstract property database_tables: list[type]

supporting tables

open_connection()[source]

open a connection to the database.

Return type:

Connection

neuralib.sqlp.cli.transaction()[source]

A decorator that decorate a function as a transaction session that open a connection and set to the global variable.

>>> @transaction
... def example(self):
...     self.do_something()

equalivent to

>>> def example(self):
...     with self.open_connection():
...         self.do_something()