Other api/dybdbipre

Table Of Contents

Previous topic

DBSRV

Next topic

DybDbi

This Page

Daya Bay Links

Content Skeleton

DybDbiPre

Tab

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

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

class/table level properties

meta
a token that identifies the key, value pairs on the line as metadata rather than a table row
table
name of the payload Database table, eg CalibFeeSpec
class
name of the generated DbiTableRow class, follow convention of naming with a G prefix eg GCalibFeeSpec
CanL2Cache
set to kFALSE, L2 caching is for debugging only
legacy
name of prior table when migrations are performed, WARNING, CURRENTLY NOT IN USE, set to table name
rctx
default read context represented by a comma delimited string, see dybgaudi:Database/DybDbi/src/DbiCtx.cxx
wctx
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 }}',
__call__(d)[source]

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