Next / Previous / Contents / NM Tech homepage

8.2. mycbc.py: Interface to the 1998 database

Here we begin file mycbc.py, a module that interfaces to the 1998 MySQL database. The interface is generally similar to the new interface described in Section 5, “Using the pycbc interface”, so the comments here will be minimal. The main difference is that the schema is determined through reflection, that is, letting SQLAlchemy probe that database for its structure.

mycbc.py
'''mycbc.py: Interface to the 1998-format CBC database

  For complete documentation:
    http://www.nmt.edu/~shipman/z/cbc/pycbc/
'''

#================================================================
# Imports
#----------------------------------------------------------------
from sqlalchemy import schema, types, orm, engine

The protocol is MySQL instead of Postgresql, and the host is the TCC general database host.

mycbc.py
#================================================================
# Manifest constants
#----------------------------------------------------------------
# The engine is mysql at dbhost.nmt.edu.
#--
URL_FORMAT = "%s://%s:%s@%s/%s"
PROTOCOL = "mysql"
DB_USER = "john"
DB_HOST = "dbhost.nmt.edu"
DB_NAME = "john"

#--
# Names of the tables.
#--
CIR_NAME = "cir"
STND_NAME = "stnd"
AS_PUB_NAME = "aspub"
EFF_NAME = "eff"
CEN_NAME = "cen"