def main(): file = open( "DATABASES_bench_result" + str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")), "w", ) file.write("Benchmarks are made with cpu :\n") file.write(cpuinfo.get_cpu_info()["brand"] + "\n\n") for idx, query in enumerate([query1, query6, query7, query9]): file.write( "Query {0} :\n".format(str(idx + 1)) + query + "\n----------------------------------------------------------\n\n") sqlalchemy_uri = os.environ.get("SQLALCHEMY_DATABASE_URI", "sqlite://") db = urlparse(sqlalchemy_uri).path.replace("/", "") engine = sqlalchemy.create_engine(sqlalchemy_uri) mdx_engine = MdxEngine(sqla_engine=engine, source_type="db") mdx_engine.load_cube(cube_name=db if db else "main", fact_table_name="facts") wsgi_application = get_wsgi_application(mdx_engine) server = WSGIServer(application=wsgi_application, host=HOST, port=PORT) server.start() for config_file in os.listdir(os.path.join(os.getcwd(), "db_config_files")): dbms = str(config_file.split("_")[0]) try: copy_2_olapy_dir(config_file) # to refresh cubes from database provider = xmla.XMLAProvider() conn = provider.connect(location=server.url) mbench = MicBench() t = PrettyTable( ["Query", "{0} - olapy execution time".format(dbms)]) for idx, query in enumerate([query1, query6, query7, query9]): if dbms.upper() in ["POSTGRES", "ORACLE"]: query = fix_query_lowercase_db(query) t.add_row([ "Query" + str(idx + 1), str(mbench.bench(conn, query, CUBE_NAME)) ]) file.write(str(t) + "\n\n") except XMLAException: type, value, traceback = sys.exc_info() print("Error opening %s" % (value)) print("Can't connect to {0} database".format(dbms)) server.stop()
def main(): file = open( "DATABASES_bench_result" + str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")), "w", ) file.write("Benchmarks are made with cpu :\n") file.write(cpuinfo.get_cpu_info()["brand"] + "\n\n") for idx, query in enumerate([query1, query6, query7, query9]): file.write( "Query {0} :\n".format(str(idx + 1)) + query + "\n----------------------------------------------------------\n\n") olapy_data = os.path.join(expanduser("~"), "olapy-data") db_config = DbConfigParser() # todo conn string db_conf = db_config.get_db_credentials( os.path.join(olapy_data, "olapy-config.yml")) xmla_tools = XmlaDiscoverReqHandler(olapy_data=olapy_data, source_type="db", db_config=db_conf, cubes_config=None) application = get_spyne_app(xmla_tools) wsgi_application = WsgiApplication(application) server = WSGIServer(application=wsgi_application, host=HOST, port=PORT) server.start() for config_file in os.listdir(os.path.join(os.getcwd(), "db_config_files")): dbms = str(config_file.split("_")[0]) try: copy_2_olapy_dir(config_file) # to refresh cubes from database provider = xmla.XMLAProvider() conn = provider.connect(location=server.url) mbench = MicBench() t = PrettyTable( ["Query", "{0} - olapy execution time".format(dbms)]) for idx, query in enumerate([query1, query6, query7, query9]): if dbms.upper() in ["POSTGRES", "ORACLE"]: query = fix_query_lowercase_db(query) t.add_row([ "Query" + str(idx + 1), str(mbench.bench(conn, query, CUBE_NAME)) ]) file.write(str(t) + "\n\n") except: type, value, traceback = sys.exc_info() print("Error opening %s" % (value)) print("Can't connect to {0} database".format(dbms)) pass server.stop()
def copy_2_olapy_dir(config_file): olapy_dir = get_olapy_dir() shutil.copy( os.path.join(os.getcwd(), "db_config_files", config_file), os.path.join(olapy_dir, "olapy-config.yml"), )