def reset(offline=False): """ Reset the htm-it database; upon successful completion, the necessary schema are created, but the tables are not populated :param offline: False to execute SQL commands; True to just dump SQL commands to stdout for offline mode or debugging """ # Make sure we have the latest version of configuration config.loadConfig() dbName = config.get('repository', 'db') resetDatabaseSQL = ("DROP DATABASE IF EXISTS %(database)s; " "CREATE DATABASE %(database)s;" % { "database": dbName }) statements = resetDatabaseSQL.split(";") engine = getUnaffiliatedEngine() with engine.connect() as connection: for s in statements: if s.strip(): connection.execute(s) migrate(offline=offline)
def engineFactory(reset=False): """SQLAlchemy engine factory method See http://docs.sqlalchemy.org/en/rel_0_9/core/connections.html :param reset: Force a new engine instance. By default, the same instance is reused when possible. :returns: SQLAlchemy engine object :rtype: sqlalchemy.engine.Engine Usage:: from htm.it.app import repository engine = repository.engineFactory() """ config.loadConfig() return htmengine.repository.engineFactory(config, reset)
def reset(offline=False): """ Reset the htm-it database; upon successful completion, the necessary schema are created, but the tables are not populated :param offline: False to execute SQL commands; True to just dump SQL commands to stdout for offline mode or debugging """ # Make sure we have the latest version of configuration config.loadConfig() dbName = config.get('repository', 'db') resetDatabaseSQL = ( "DROP DATABASE IF EXISTS %(database)s; " "CREATE DATABASE %(database)s;" % {"database": dbName}) statements = resetDatabaseSQL.split(";") engine = getUnaffiliatedEngine() with engine.connect() as connection: for s in statements: if s.strip(): connection.execute(s) migrate(offline=offline)
def getDbDSN(): config.loadConfig() return htmengine.repository.getDbDSN(config)
def getDbDSN(): config.loadConfig() return DB_DSN_FORMAT % dict(config.items("repository"))