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 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 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 executor(request): config = None custom = False if hasattr(request, "param"): custom = request.param config = cube_config sqlalchemy_uri = "sqlite://" else: sqlalchemy_uri = os.environ.get("SQLALCHEMY_DATABASE_URI", "") if not sqlalchemy_uri: sqlalchemy_uri = "sqlite://" db_test = urlparse(sqlalchemy_uri).path.replace("/", "") engine = sqlalchemy.create_engine(sqlalchemy_uri) create_insert(engine, custom) mdx_engine = MdxEngine(sqla_engine=engine, source_type="db", cube_config=config) mdx_engine.load_cube( cube_name=db_test if db_test else "main", fact_table_name="facts" ) yield mdx_engine drop_tables(engine, custom)
def main(): file = open( "bench_result" + str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")), "w") gen = CubeGen(number_dimensions=3, rows_length=1000, columns_length=5) gen.generate_csv(gen.generate_cube(3, 1000)) mbench = MicBench() file.write("Benchmarks are made with cpu :\n") file.write(cpuinfo.get_cpu_info()["brand"] + "\n\n") mdx_engine = MdxEngine() mdx_engine.load_cube(CUBE_NAME) wsgi_application = get_wsgi_application(mdx_engine) server = WSGIServer(application=wsgi_application, host=HOST, port=PORT) server.start() provider = xmla.XMLAProvider() conn = provider.connect(location=server.url) olapy_query_execution_bench(file, mbench, conn, mdx_engine) olapy_vs_mondrian(file, mbench, conn) olapy_vs_iccube(file, mbench, conn) olapy_profile(file) gen.remove_temp_cube() file.close() server.stop()
def main(): executor = MdxEngine() executor.load_cube("sales") execution_result = executor.execute_mdx(mdx_query) print(execution_result["result"])
# -*- coding: utf-8 -*- """ Created on Tue Oct 1 14:35:13 2019 @author: patemi """ from olapy.core.mdx.executor import MdxEngine executor = MdxEngine() # instantiate the MdxEngine executor.load_cube('sales') # load sales cube