Пример #1
0
 def _do_migrations():
     current_dir = os.path.dirname(__file__)
     migrations_dir = os.path.join(current_dir, 'migrations')
     conn = components.get_psql()
     exceptions.register(DatabaseError)
     migrations = read_migrations(conn, 'pyformat', migrations_dir)
     migrations.to_apply().apply()
     conn.commit()
Пример #2
0
 def _do_migrations():
     current_dir = os.path.dirname(__file__)
     migrations_dir = os.path.join(current_dir, 'migrations')
     conn = components.get_psql()
     exceptions.register(DatabaseError)
     migrations = read_migrations(conn, 'pyformat', migrations_dir)
     migrations.to_apply().apply()
     conn.commit()
Пример #3
0
def get_all() -> list:
    """
    Gets list of all users in the DB.
    If any error occurs when pulling data from the DB, we use cached data in the Redis.
    If even that fails, exception will be raised.
    :return: list
    """
    try:
        db = components.get_psql()
        redis = components.get_redis()
        result = _get_all_from_db(db)
        _save_all_to_redis(redis, result)
        return result
    except psycopg2.DatabaseError:
        return _get_all_from_redis(components.get_redis())
Пример #4
0
 def __init__(self):
     self._ddl_conn = components.get_psql()
     self._ddl_conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
     self._name = generate_name()
     self._create_database()
     self._conn = components.get_psql(dbname=self._name)
Пример #5
0
 def __init__(self):
     self._ddl_conn = components.get_psql()
     self._ddl_conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
     self._name = generate_name()
     self._create_database()
     self._conn = components.get_psql(dbname=self._name)