Other api/dybdbipre

Table Of Contents

Previous topic


Next topic


This Page

Daya Bay Links

Content Skeleton



class DybDbiPre.Tab[source]

Bases: list

DybDbiPre.Tab instances are created by the parsing of .spec files (dybgaudi:Database/DybDbi/spec). Instances contain a list of dicts corresponding to each payload row in the DBI table together with a metadata dictionary for class level information.

To test the parsing of a .spec file, use for example:

cat $DYBDBIROOT/spec/GSimPmtSpec.spec | python $DYBDBIPREROOT/python/DybDbiPre/__init__.py

The instances are available in the django context used to fill templates dybgaudi:Database/DybDbi/templates used in the generation of:

  1. DbiTableRow subclasses allowing DBI to interact with the table
  2. Documentation presenting the DBI tables in .tex and wiki formats
  3. SQL scripts for table creation .sql

The meanings of the quantities in the .spec are ultimately determined by their usage in the templates, however some guideline definitions are listed below:

row level quantities

column name as used in C++ getter and setter methods
MySQL column type name used in table description, such as double or int(10) unsigned
type used in generated C++ code, eg DayaBay::FeeChannelId
name of the column in database table
short definition of the meaning of the column
C++ converter function used to translate a value in code into a value stored in the DB, eg .fullPackedData()
name of the column data member in the C++ table row class, WARNING, CURRENTLY NOT IN USE

class/table level properties

a token that identifies the key, value pairs on the line as metadata rather than a table row
name of the payload Database table, eg CalibFeeSpec
name of the generated DbiTableRow class, follow convention of naming with a G prefix eg GCalibFeeSpec
set to kFALSE, L2 caching is for debugging only
name of prior table when migrations are performed, WARNING, CURRENTLY NOT IN USE, set to table name
default read context represented by a comma delimited string, see dybgaudi:Database/DybDbi/src/DbiCtx.cxx
default write context range represented by a comma delimited string, see dybgaudi:Database/DybDbi/src/DbiCtx.cxx

usage in templates

The class level and row level quantities are used in django templates with expressions of the form:

{{ t.meta.table }}   

{% for r in t %}`{{ r.name }}` {{ r.dbtype }} default NULL COMMENT '{{ r.description }}',

If fields in the .spec file include a “meta” key then the fieldname(ie key),value pairs are included into the meta dictionary