コード例 #1
0
async def run():
    db_name = make_url(DATABASE_URL).database
    sync_database_url = DATABASE_URL.replace("TEST_", "")
    engine = create_engine(sync_database_url)

    if not database_exists(sync_database_url, db_name):
        create_database(sync_database_url, db_name)
        metadata.create_all(engine)
    else:
        metadata.drop_all(engine)
        metadata.create_all(engine)
コード例 #2
0
ファイル: prepare_db.py プロジェクト: madEng84/pycon
async def run():
    engine = get_engine(echo=False)
    metadata = mapper_registry.metadata

    if not database_exists(DATABASE_URL):
        create_database(DATABASE_URL)

        async with engine.begin() as connection:
            await connection.run_sync(mapper_registry.metadata.create_all)
    else:
        async with engine.begin() as connection:
            for table in metadata.sorted_tables:
                await connection.execute(table.delete())
コード例 #3
0
async def run():
    engine = get_engine(echo=False)
    metadata = mapper_registry.metadata
    db_name = make_url(DATABASE_URL).database
    sync_database_url = DATABASE_URL.replace("asyncpg",
                                             "psycopg2").replace("TEST_", "")

    if not database_exists(sync_database_url, db_name):
        create_database(sync_database_url, db_name)

        async with engine.begin() as connection:
            await connection.run_sync(metadata.create_all)
    else:
        async with engine.begin() as connection:
            await connection.run_sync(metadata.drop_all)
            await connection.run_sync(metadata.create_all)
コード例 #4
0
def _setup_db():
    if not does_database_exist():
        log.info("Database missing. Attempting to create")
        if create_database():
            if initialize_database():
                log.info("Database successfully initialized")
            else:
                log.error("Error encountered initalizing database")
        else:
            log.error("Error encountered creating database")
    else:
        if not verify_schema():
            if initialize_database():
                log.info("Database successfully initialized")
コード例 #5
0
def _setup_db():
    if not does_database_exist():
        log.info("Database missing. Attempting to create")
        if create_database():
            if initialize_database():
                log.info("Database successfully initialized")
            else:
                log.error("Error encountered initalizing database")
        else:
            log.error("Error encountered creating database")
    else:
        if not verify_schema():
            if initialize_database():
                log.info("Database successfully initialized")
コード例 #6
0
Created on Mon Jan 27 17:32:00 2020

@author: Design
"""
filePath = "C:\\Users\\Design\\Documents\\Python Scripts\\ENDF-B-VIII.0_decay"
#fileName = "dec-027_Co_060.endf"

if os.path.isfile('log.temp'):
    os.remove('log.temp')
if os.path.isfile("database451.sql"):
    os.remove("database451.sql")

logFile = open('log.temp', 'w')
con = create_connection("localhost", "root", "Password")
cur = con.cursor()
create_database(cur, "database451")
cur.execute("USE database451")
table451 = """
CREATE TABLE table451 (
id integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
ZA integer NOT NULL, AWR real NOT NULL, LRP integer NOT NULL,
LFI integer NOT NULL, NLIB integer NOT NULL, NMOD integer NOT NULL,
ELIS integer NOT NULL, STA integer NOT NULL, LIS integer NOT NULL,
LISO integer NOT NULL, NFOR integer NOT NULL,
AWI integer NOT NULL, EMAX integer NOT NULL, LREL integer NOT NULL,
NSUB integer NOT NULL, NVER integer NOT NULL,
TEMP integer NOT NULL, LDRV integer NOT NULL, NWD integer NOT NULL,
NXC integer NOT NULL,
ZSAYM text NOT NULL, ALAB text NOT NULL, EDATE text NOT NULL,
REF text NOT NULL, DDATE text NOT NULL, ENDATE text NOT NULL,
HSUB text NOT NULL, ABUND real NOT NULL) """