Ejemplo n.º 1
0
def create_tables():
    Base.metadata.create_all(
        bind=connect_to_database(user_name=db_user,
                                 user_password=db_password,
                                 database_host=db_host,
                                 database_port=db_port,
                                 database_name=database_name))
Ejemplo n.º 2
0
def create_database():
    #  Create database.
    execute_postgres_command(
        engine=connect_to_database(user_name=db_user,
                                   user_password=db_password,
                                   database_host=db_host,
                                   database_port=db_port,
                                   database_name=db_user),
        command='CREATE DATABASE {}'.format(database_name))
    execute_postgres_command(
        engine=connect_to_database(user_name=db_user,
                                   user_password=db_password,
                                   database_host=db_host,
                                   database_port=db_port,
                                   database_name=db_user),
        command=(
            'REVOKE connect ON DATABASE {} FROM PUBLIC'.format(database_name)))
def drop_database():
    execute_postgres_command(engine=connect_to_database(
        user_name=db_user,
        user_password=db_password,
        database_host=db_host,
        database_port=db_port,
        database_name=db_user),
                             command='DROP DATABASE {}'.format(database_name))