Db¶
-
class
baboossh.
Db
[source]¶ A singleton handling the database connection
This class allows the use of a single sqlite connection for earch thread
-
__init__
()¶ Initialize self. See help(type(self)) for accurate signature.
Methods
Initialize self.
build
(workspace)Create the databases and the tables for a new
Workspace
close
()Closes the connection for the current Thread
connect
(workspace)Open the connection to the database for a
Workspace
get
()Returns the database connection for the current thread
-
classmethod
build
(workspace)[source]¶ Create the databases and the tables for a new
Workspace
- Parameters
workspace (str) – the workspace’s name
-
classmethod
connect
(workspace)[source]¶ Open the connection to the database for a
Workspace
If this function is called from the main thread, it closes existing sqlite connections and opens a new one. Else, if a connection isn’t already open for the current thread, it opens the connection.
- Parameters
workspace (str) – the name of the Workspace to open
- Raises
ValueError – raised if the database file doesn’t exist
-