vdat.database – The VDAT database

The database

Database management for VDAT

vdat.database.core.init(redux_dir=None, remove_old=True)[source]

Initialise the database

Parameters:
redux_dir : string, optional

if given, create a physical database, otherwise creates it in memory

remove_old : bool, optional

drop existing tables if true

Fields and Models

Database management for VDAT

exception vdat.database.models.MergeTypeError[source]

Bases: vdat.database.base.VDATDBError, TypeError

Raised when merging table entries of different types

class vdat.database.models.BoolField(null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, db_column=None, _hidden=False)[source]

Bases: peewee.Field

sqlite doesn’t play well with boolean, apparently. This field coerce True and False into strings "true" and "false" and vice versa

db_field = 'text'
db_value(value)[source]

Convert the input bool into a string

python_value(value)[source]

Convert the input string into a bool

class vdat.database.models.VDATDir(*args, **kwargs)[source]

Bases: vdat.database.base.VDATModels

Redux directories metadata

version = '1.0'
version_f = <TextField: VDATDir.version_f>
redux_dir = <TextField: VDATDir.redux_dir>
night = <TextField: VDATDir.night>
type_ = <TextField: VDATDir.type_>
name = <TextField: VDATDir.name>
path = <TextField: VDATDir.path>
is_clone = <BoolField: VDATDir.is_clone>
shot = <TextField: VDATDir.shot>
timestamp = <DateTimeField: VDATDir.timestamp>
original_type_ = <TextField: VDATDir.original_type_>
object_ = <TextField: VDATDir.object_>
zero_dir = <ForeignKeyField: VDATDir.zero_dir>
cal_dir = <ForeignKeyField: VDATDir.cal_dir>
make_path()[source]

Fill the path field joining redux_dir, night, type_ and name

merge_entries(others, exclude=['id', 'zero_dir', 'cal_dir', 'ifus'])[source]

Merge the self with other excluding exclude.

The merging is done using vdat.utilities.merge_dicts()

Parameters:
other : (list of) VDATDir instance

list of models to merge with

exclude : list of strings

list of field names to ignore when merging

Raises:
MergeTypeError

if the types of others are not the same as the owner class

data_clean

Expose the internal data of the model without the id and without recursing the foreign keywords

Returns:
dict

dictionary of data

DoesNotExist

alias of VDATDirDoesNotExist

_meta = <peewee.Metadata object>
_schema = <peewee.SchemaManager object>
cal_dir_id = <ForeignKeyField: VDATDir.cal_dir>
id = <AutoField: VDATDir.id>
target_cal_dir
target_zero_dir
zero_dir_id = <ForeignKeyField: VDATDir.zero_dir>
class vdat.database.models.VDATExposures(*args, **kwargs)[source]

Bases: vdat.database.base.VDATModels

Redux directories metadata

version = '1.0'
version_f = <TextField: VDATExposures.version_f>
path = <TextField: VDATExposures.path>
name = <TextField: VDATExposures.name>
basename = <TextField: VDATExposures.basename>
expname = <TextField: VDATExposures.expname>
exptype = <TextField: VDATExposures.exptype>
original_type = <TextField: VDATExposures.original_type>
object_ = <TextField: VDATExposures.object_>
DoesNotExist

alias of VDATExposuresDoesNotExist

_meta = <peewee.Metadata object>
_schema = <peewee.SchemaManager object>
id = <AutoField: VDATExposures.id>

The base

Base definitions common to all the other modules in the subpackage

exception vdat.database.base.VDATDBError[source]

Bases: Exception

Base exceptions for database errors

class vdat.database.base.VDATModels(*args, **kwargs)[source]

Bases: peewee.Model

Base class for linking models with the VDAT database

data

Expose the full internal data of the model

Returns:
dict

dictionary of data

data_noid

Expose the internal data of the model excluding the id

Returns:
dict

dictionary of data

data_clean

Expose the internal data of the model without the id and without recursing the foreign keywords

Returns:
dict

dictionary of data

DoesNotExist

alias of VDATModelsDoesNotExist

_meta = <peewee.Metadata object>
_schema = <peewee.SchemaManager object>
id = <AutoField: VDATModels.id>