def conn(): engine = sqlalchemy.create_engine("sqlite://") create_insert(engine) executor = MdxEngine(sqla_engine=engine, source_type="db") executor.load_cube(cube_name="main", fact_table_name="facts") discover_request_hanlder = XmlaDiscoverReqHandler(executor) execute_request_hanlder = XmlaExecuteReqHandler(executor) print("spawning server") application = Application( [XmlaProviderService], "urn:schemas-microsoft-com:xml-analysis", in_protocol=Soap11(validator="soft"), out_protocol=Soap11(validator="soft"), config={ "discover_request_hanlder": discover_request_hanlder, "execute_request_hanlder": execute_request_hanlder, }, ) wsgi_application = WsgiApplication(application) server = WSGIServer(application=wsgi_application, host=HOST, port=PORT) server.start() provider = xmla.XMLAProvider() yield provider.connect(location=server.url) print("stopping server") drop_tables(engine) server.stop()
def benchmark(): mdx_executor = MdxEngine(cubes_folder="cubes_templates", olapy_data_location="../../../olapy") mdx_executor.load_cube(BENCH_CUBE) xmla_discover_request_handler = XmlaDiscoverReqHandler(mdx_executor) xmla_execute_request_handler = XmlaExecuteReqHandler(mdx_executor) return run_benchmark(mdx_executor, xmla_discover_request_handler, xmla_execute_request_handler)
def _get_xmla_tools(): olapy_data = os.path.join(expanduser("~"), "olapy-data") mdx_executor = MdxEngine() mdx_executor.load_cube(CUBE_NAME) xmla_tools = XmlaDiscoverReqHandler( executor=mdx_executor, olapy_data=olapy_data, source_type="csv", db_config=None, cubes_config=None, ) return xmla_tools
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()