12. Module Reference¶
This chapter contains all the documentation auto-generated from the source code. It is probably not terribly useful for reading through, but may be useful as a searchable reference.
Contains the functions that make up the piw-initdb script.
This is the main function for the piw-initdb script. It creates the piwheels database required by the master or, if it already exists, upgrades it to the current version of the application.
Test that the user for conn is a cluster superuser (so we can drop and create anything we want in the database), and that test_user (which will be granted limited rights to various objects for the purposes of the piw-master script) exists and is not a cluster superuser.
Detect the version of the database. This is typically done by reading the contents of the
configurationtable, but before that was added we can guess a couple of versions based on what tables exist (or don’t). Returns
Noneif the database appears uninitialized, and raises
RuntimeErroris the version is so ancient we can’t do anything with it.
Return an SQLAlchemy connection to the specified dsn or raise
RuntimeErrorif the database doesn’t exist (the administrator is expected to create the database before running this script).
Generate the script to get the database from version (the result of
detect_version()) to the current version of the software. If version is
None, this is simply the contents of the
sql/create_piwheels.sqlscript. Otherwise, it is a concatenation of various update scripts.
This is an extremely crude statement splitter for PostgreSQL’s dialect of SQL. It understands
$delim$ extended strings $delim$, but not
/* C-style comments */. If you start using such things in the update scripts, you’ll need to extend this function to accommodate them.
It returns a generator which yields individiual statements from script, delimited by semi-colon terminators.