HWRF
trunk@4391
|
Stores information about Datum objects in a database. More...
Stores information about Datum objects in a database.
Stores and retrieves Datum objects from an sqlite3 database. Uses file locking workarounds for bugs in RedHat Enterprise Linux's sqlite3 library, which is compiled without proper locking. Has support for caching, and multithreading. Each object in this database has a type, a string location, an integer "available" parameter, and an arbitrary list of (key,value) metadata pairs. This object can safely be accessed by multiple threads in the local process, and handles concurrency between processes via file locking.
Definition at line 134 of file datastore.py.
Public Member Functions | |
def | __init__ |
Datastore constructor. More... | |
def | transaction (self) |
Starts a transaction on the database in the current thread. More... | |
def | dump (self) |
Print database contents to the terminal. More... | |
Public Attributes | |
filename | |
The path to the sqlite3 database file. | |
db | |
The underlying sqlite3 database object. | |
def produtil.datastore.Datastore.__init__ | ( | self, | |
filename, | |||
logger = None , |
|||
locking = True |
|||
) |
Datastore constructor.
Creates a Datastore for the specified sqlite3 file. Uses the given logging.Logger object for logging messages. Set locking=False to disable all file locking. That is generally unwise, and should only be used when reading the database. That functionality is supplied, and critical, for monitoring another user's jobs. One cannot lock another user's file, so the "no locking" option is the only way to analyze the other user's simulation.
filename | the filename passed to sqlite3.connect |
logger | a logging.Logger to use for logging messages |
locking | should file locking be used? It is unwise to turn off file locking. |
Definition at line 146 of file datastore.py.
def produtil.datastore.Datastore.dump | ( | self | ) |
Print database contents to the terminal.
This function is only meant for debugging. It dumps to the terminal an arguably human-readable display of the complete database state via the print command.
Definition at line 241 of file datastore.py.
def produtil.datastore.Datastore.transaction | ( | self | ) |
Starts a transaction on the database in the current thread.
Definition at line 225 of file datastore.py.
Referenced by produtil.datastore.Datum.__delitem__(), produtil.datastore.Datum.__setitem__(), produtil.datastore.Datastore.dump(), and produtil.datastore.Datum.set_loc_avail().