示例#1
0
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)
示例#2
0
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)
示例#3
0
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)
示例#4
0
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)
示例#5
0
def getDbDSN():
    config.loadConfig()
    return htmengine.repository.getDbDSN(config)
示例#6
0
def getDbDSN():
  config.loadConfig()
  return DB_DSN_FORMAT % dict(config.items("repository"))
示例#7
0
def getDbDSN():
  config.loadConfig()
  return htmengine.repository.getDbDSN(config)
示例#8
0
def getDbDSN():
    config.loadConfig()
    return DB_DSN_FORMAT % dict(config.items("repository"))