HWRF  trunk@4391
Public Member Functions | Public Attributes | List of all members
produtil.datastore.Datastore Class Reference

Stores information about Datum objects in a database. More...

Detailed Description

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.

Inheritance diagram for produtil.datastore.Datastore:

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.
 

Constructor & Destructor Documentation

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.

Parameters
filenamethe filename passed to sqlite3.connect
loggera logging.Logger to use for logging messages
lockingshould file locking be used? It is unwise to turn off file locking.
Warning
Setting locking=False will disable file locking at both the Datastore level, and within sqlite3 itself. This can lead to database corruption if two processes try to write at the same time. This functionality is provided for the rare situation where you are unable to write to a database, such as when reading other users' sqlite3 database files.

Definition at line 146 of file datastore.py.

Member Function Documentation

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().


The documentation for this class was generated from the following file: