Exemplo n.º 1
0
db_name = args.db_name
ddl_path = args.ddl_path
db_path = args.db_path
url_mssql = args.mssql_url
pg_url = args.pg_url

downloader = MSSQLDownloader(mssql_queries, url_mssql)
print("downloading db from " + url_mssql)
schema = downloader.load('dbo')
converter = Converter()
converter.convertRam2Xml(schema, result_path + 'dbo.xml')

ddl_generator = DBInitialisator()
ddl = ddl_generator.generate_ddl(schema)
Writer.write(ddl_path + schema.name + ".ddl", '\n'.join(ddl))
print("ddl saved to {}".format(ddl_path + schema.name + ".ddl"))

pg_init = DBInitialisator()

conn = postgresql.open(pg_url)
conn.execute(pg_init.drop_database(db_name))
print("creating database {}".format(db_name))
conn.execute(pg_init.create_database_ddl(db_name))
conn.close()
print("connecting to database {}".format(db_name))
conn = postgresql.open(pg_url + '/' + db_name.lower())

conn.execute('\n '.join(ddl))

data_transfer = DataTransfering(db_name, mssql_url,
Exemplo n.º 2
0
    hit10 = np.sum(ranks <= 10, axis=0) / len(ranks)
    mrr_sum = (1. / ranks).sum(axis=0)
    mrr = np.tile(
        np.array([mrr_sum[0] + mrr_sum[2], mrr_sum[1] + mrr_sum[3]]) /
        (2 * len(ranks)), 2)
    result = pd.DataFrame({
        "mrr": mrr,
        "mean rank": mean_rank,
        "hit10": hit10
    },
                          index=[
                              "tail: raw ranking", "tail: filtered ranking",
                              "head: raw ranking", "head: filtered ranking"
                          ])
    result["hit10"] = result["hit10"].apply(lambda x: "%.2f%%" % (x * 100))
    ranks = pd.DataFrame(
        ranks,
        columns=["tail:raw", "tail:filtered", "head:raw", "head:filtered"])
    return ranks, result


dis.eval()
ranks, result = evaluate()

writer = Writer(configs)
logger = Logger(configs)
writer.write(result)

if configs.log:
    logger.write(ranks)
Exemplo n.º 3
0
elif db:
    print("reading database {} ".format(db))
    db_downloader = DBDownloader(sqlite_queries, db, None)
    schemas_from_db = db_downloader.load()
    schemas = schemas_from_db
    arr = db.replace('.db', '').split('\\')
    db_name = arr[arr.__len__() - 1]

pg_init = DBInitialisator()

print("establishing connection...")
url = postgressql_url
conn = postgresql.open(url)
conn.execute(pg_init.drop_database(db_name))
print("creating database {}".format(db_name))
conn.execute(pg_init.create_database_ddl(db_name))
conn.close()
print("connecting to database {}".format(db_name))
conn = postgresql.open(url + '/' + db_name.lower())

for schema in schemas.values():
    print("generating ddl for schema {}".format(schema.name))
    ddl = pg_init.generate_ddl(schema)  # generate ddl instructions
    Writer.write(ddl_path + db_name + ".ddl", '\n '.join(ddl))
    print("ddl saved to {}".format(ddl_path + db_name + ".ddl"))
    conn.execute('\n '.join(ddl))
    print("schema '{}' was created".format(schema.name))

conn.close()