pygcam.mcs.database¶
API¶
This module includes contributions by Sam Fendell and Ryan Jones.
- pygcam.mcs.database.beforeSavingRun(_mapper, _connection, run)¶
Before inserting/updating a Run instance, set numerical status and timestamps according to the status string.
- pygcam.mcs.database.canonicalizeRegion(name)¶
Return the canonical name for a region, normalizing the use of capitalization and underscores.
- Parameters
name – a GCAM region name
- Returns
region name in canonical format, i.e., lowercase with underscores changed to spaces. (The use of underscores is inconsistent and thus hard to remember, e.g., ‘South America_Northern’)
- pygcam.mcs.database.getDatabase(checkInit=True)¶
Return the instantiated CoreDatabase, or created one and return it. The optional dbClass argument is provided to facilitate subclassing.
- pygcam.mcs.database.parseSqlScript(filename=None, text=None)¶
Parse a SQL script into semi-colon-terminated statements.
- Parameters
filename – (str) the path of the file of SQL statements
text – (str) optionally pass the contents of the file rather than the filename
- Returns
(list of str) the individual statements
- pygcam.mcs.database.sqlite_FK_pragma(dbapi_connection, connection_record)¶
Turn on foreign key support in sqlite
- pygcam.mcs.database.usingPostgres()¶
Return True if the DbURL indicates that we’re using Postgres, else return False
- pygcam.mcs.database.usingSqlite()¶
Return True if the DbURL indicates that we’re using Sqlite, else return False