Database Module

Database server module

class iceprod.server.modules.db.db(*args, **kwargs)[source]

Handle all interaction with the local database

start()[source]

Start database

stop()[source]
kill()[source]
exception iceprod.server.modules.db.DBResetError[source]
iceprod.server.modules.db.read_db_conf(field_name=None)[source]

Read the DB conf data from file.

Parameters:field_name (string) – (optional) field to return
Returns:Either a specific field, or all fields in a dict
class iceprod.server.modules.db.DBAPI(parent)[source]

API for database interaction

Config data (such as tables) are found at DB Config.

archive_tables = [u'site', u'node', u'dataset', u'dataset_notes', u'dataset_stat', u'job', u'job_stat', u'task', u'task_stat', u'task_log', u'config', u'resource', u'data']
indices = {u'search': [u'dataset_id', u'task_status', u'job_id'], u'task': [u'task_rel_id'], u'task_log': [u'task_id'], u'task_rel': [u'dataset_id'], u'job': [u'dataset_id', u'status,dataset_id'], u'task_lookup': [u'queue']}
status_options = {u'job': [u'processing', u'complete', u'suspended', u'errors'], u'task': [u'idle', u'waiting', u'queued', u'processing', u'complete', u'suspended', u'failed', u'resume', u'reset'], u'dataset': [u'processing', u'truncated', u'complete', u'suspended', u'errors']}
init()[source]

Initialize the settings table, if necessary.

acquire_lock(lock_name='_none_')[source]

Yield a tornado.locks.Lock for a specific task.

This is designed to be used in a context-manager:

with (yield db.acquire_lock(‘task1’)):
# do something
Parameters:lock_name (str) – The name of the task
increment_id(*args, **kwargs)[source]

Increment the id of a table, returning the old value.

Parameters:table_name (str) – The name of the table
Returns:A table id
Return type:str
query(*args, **kwargs)[source]

Execute a database query.

If this is a read (SELECT) query, it will return an iterator over rows. If this is a write (INSERT, UPDATE, REPLACE) query, it will return None.

Parameters:
  • sql (str) – The query to execute
  • bindings (tuple) – The bindings, if any
Returns:

iterator or None

class iceprod.server.modules.db.SQLite(*args, **kwargs)[source]

SQLite 3 implementation of DBAPI

class iceprod.server.modules.db.MySQL(parent)[source]

MySQL 5 implementation of DBAPI