Exemple #1
0
def connection(request):
    """Return a connection to a database"""
    conn = get_database(":memory:", SCHEMA)
    def teardown():
        print('\n')
        logger.info('Closing connection')
        conn.close()
        logger.debug('Connection closed')
    request.addfinalizer(teardown)
    
    return conn
Exemple #2
0
def init(ctx, db_name, path):
    """Create a config file for phizz."""
    config = ConfigObj()
    config.filename = config_file

    database = db_name

    if os.path.exists(database):
        logger.error("Databse already exists in {0}".format(database))
        sys.exit(1)

    logger.info("Set database to {0}".format(database))
    config["database"] = database

    config.write()

    conn = get_database(path_to_database=database, database_schema=schema_path)

    build_database(conn)
Exemple #3
0
def init(ctx, db_name, path):
    """Create a config file for phizz."""
    config = ConfigObj()
    config.filename = config_file

    database = db_name

    if os.path.exists(database):
        logger.error("Databse already exists in {0}".format(database))
        sys.exit(1)

    logger.info("Set database to {0}".format(database))
    config["database"] = database

    config.write()

    conn = get_database(path_to_database=database, database_schema=schema_path)

    build_database(conn)
Exemple #4
0
def test_get_database_no_schema():
    """docstring for test_database"""
    #Should provide a schema
    with pytest.raises(IOError):
        connection = get_database(":memory:")
Exemple #5
0
def test_get_database():
    """docstring for test_database"""

    connection = get_database(":memory:", SCHEMA)
    assert connection
Exemple #6
0
def test_get_database_no_schema():
    """docstring for test_database"""
    #Should provide a schema
    with pytest.raises(IOError):
        connection = get_database(":memory:")
Exemple #7
0
def test_get_database():
    """docstring for test_database"""
    
    connection = get_database(":memory:", SCHEMA)
    assert connection