""" TRIADB-TriaClick Demo with Supplier-Part-Catalog (SPC) DataModel/DataSet How to build new associations using Python namedtuple from `collections` (C) October 2019 By Athanassios I. Hatzis """ from triadb import MIS mis = MIS(debug=2) mis.connect_to_datastore(dbms='clickhouse', host='localhost', port=9000, user='******', password='******', database='TriaDB', trace=0) mis.connect_to_metastore(dbms='mariadb', host='localhost', port=3306, user='******', password='******', database='TRIADB', trace=0) # Set DataModel eng = mis.restart(200, reset=True) print(mis) print(eng)
""" TRIADB Modules Testing: creating an instance of top level management information system object (MIS) testing `rebuild` and `erase` flags for rebuilding or erasing TriaDB (MariaDB database) This is the first script you run after installing `triadb` package to populate TriaDB meta-data management system with DataModels and DataSets (See README.rst) (C) October 2019 By Athanassios I. Hatzis """ from triadb import ETL, MIS mis = MIS(debug=2, rebuild=False, erase=False) mis.connect_to_datastore(dbms='clickhouse', host='localhost', port=9000, user='******', password='******', database='TriaDB', trace=0) mis.connect_to_metastore(dbms='mariadb', host='localhost', port=3306, user='******', password='******', database='TRIADB', trace=0) # NEW DataResourceSystem, DataModelSystem mis.set_drs() mis.set_dms() print(mis) # ************************************************************************************************************ # Add Data Models # ************************************************************************************************************
""" TRIADB Modules Testing: creating an instance of top level management information system object (MIS) get_tables(), get_fields(), get() methods of triadb.subsystems.DataModelSystem switching and setting DataResourceSystem objects (C) October 2019 By Athanassios I. Hatzis """ from triadb import MIS mis = MIS(debug=1) mis.connect_to_datastore(dbms='clickhouse', host='localhost', port=9000, user='******', password='******', database='TriaDB', trace=0) mis.connect_to_metastore(dbms='mariadb', host='localhost', port=3306, user='******', password='******', database='TRIADB', trace=0) # Get an overview of the DataResourcesSystem mis.get(what='datasets') # Initialize MIS with a data resource datres = mis.set_drs(242, 0) print(mis)
""" TRIADB-TriaClick Demo with Supplier-Part-Catalog (SPC) DataModel/DataSet HyperAtom Collection (HACOL) Operations (C) October 2019 By Athanassios I. Hatzis """ from triadb import MIS mis = MIS(debug=2) mis.connect_to_datastore(dbms='clickhouse', host='localhost', port=9000, user='******', password='******', database='TriaDB', trace=0) mis.connect_to_metastore(dbms='mariadb', host='localhost', port=3306, user='******', password='******', database='TRIADB', trace=0) # Set DataModel eng = mis.restart(200, reset=True) mis.dms.get() mis.dms.get_entities()
""" TRIADB-TriaClick Demo with Northwind Traders DataModel/DataSet Associative Entity Set Operations (Filtering) (C) October 2019 By Athanassios I. Hatzis """ from triadb import MIS mis = MIS(debug=1) mis.connect_to_datastore(dbms='clickhouse', host='localhost', port=9000, user='******', password='******', database='TriaDB', trace=0) mis.connect_to_metastore(dbms='mariadb', host='localhost', port=3306, user='******', password='******', database='TRIADB', trace=0) eng = mis.restart(500, 363, reset=True) print(mis) # Make multiple values selection for Customer Country mis.select('Brazil, Mexico, Argentina', In=True, alias='c_country')
""" TRIADB Modules Testing: creating an instance of top level management information system object (MIS) testing restart(), get_parts(), get_columns(), get_table_engines(), get_last_query_info() methods these are methods that operate on ClickHouse merge-tree table engines (C) October 2019 By Athanassios I. Hatzis """ from triadb import MIS # =========================================================================== # Create a Management Information System (MIS) object and connect to DBMS # =========================================================================== mis = MIS(debug=1) mis.connect_to_metastore(dbms='mariadb', host='localhost', port=3306, user='******', password='******', database='TRIADB', trace=0) mis.connect_to_datastore(dbms='clickhouse', host='localhost', port=9000, user='******', password='******', database='TriaDB', trace=0) # =========================================================================== # Select DataModel, DataResource, Start MIS # =========================================================================== mis.get(what='datasets') mis.get(what='models') mis.restart(200, 242) print(mis) # Parts, Columns, Engines, Info mis.get_parts(alias='hatom')
""" TRIADB-TriaClick Demo with Northwind Traders DataModel/DataSet Associative Entity Set Count Operations (C) October 2019 By Athanassios I. Hatzis """ from triadb import MIS mis = MIS(debug=1) mis.connect_to_datastore(dbms='clickhouse', host='localhost', port=9000, user='******', password='******', database='TriaDB', trace=0) mis.connect_to_metastore(dbms='mariadb', host='localhost', port=3306, user='******', password='******', database='TRIADB', trace=0) # Set DataModel eng = mis.restart(500, reset=False) # ------------------------------------------------------------------------ # Counting
""" TRIADB Modules Testing: creating an instance of top level management information system object (MIS) add_datamodel(), add_entity(), add_attribute() methods of triadb.subsystems.DataModelSystem adding data model components (Models, Entities, Attributes) with commands (C) October 2019 By Athanassios I. Hatzis """ from triadb import MIS mis = MIS(debug=3, erase=False) mis.connect_to_datastore(dbms='clickhouse', host='localhost', port=9000, user='******', password='******', database='TriaDB', trace=3) mis.connect_to_metastore(dbms='mariadb', host='localhost', port=3306, user='******', password='******', database='TRIADB', trace=3) print(mis) # Create a new instance of Data Model SPC = mis.set_dms()
(C) October 2019 By Athanassios I. Hatzis Data model here is a hypergraph of 3 entities with 15 attributes in total Data resources are 3 MYSQL tables with 17 fields in total NOTICE1: In the following mapping procedure, all the fields from the three sets collectively are mapped onto attributes NOTICE2: If you set rebuild=True flag it will rebuild ClickHouse TRIADB database """ from triadb import MIS # =========================================================================== # Create a Management Information System (MIS) object and connect to DBMS # =========================================================================== mis = MIS(debug=1, rebuild=True, what='data') mis.connect_to_metastore(dbms='mariadb', host='localhost', port=3306, user='******', password='******', database='TRIADB', trace=0) mis.connect_to_datastore(dbms='clickhouse', host='localhost', port=9000, user='******', password='******', database='TriaDB',
""" TRIADB-TriaClick Demo with Supplier-Part-Catalog (SPC) DataModel/DataSet Associative Entity Set Operations (Selections, Filtering, Counting, Restarting...) (C) October 2019 By Athanassios I. Hatzis """ from triadb import MIS mis = MIS(debug=3) mis.connect_to_datastore(dbms='clickhouse', host='localhost', port=9000, user='******', password='******', database='TriaDB', trace=0) mis.connect_to_metastore(dbms='mariadb', host='localhost', port=3306, user='******', password='******', database='TRIADB', trace=0) # =========================================================================== # Select DataModel, DataResource, Start MIS # =========================================================================== eng = mis.restart(500, reset=True) print(mis) print(eng) mis.get_attributes(select='dim2, cname, alias') mis.get_entities(select='dim2, cname, alias') mis.get_asets() # Selections Set selections = [ eng.set_hacol(alias='p_color').cql.Select().Where("$v='Red'"), eng.set_hacol(alias='c_price').cql.Select().Where('$v<20'), eng.set_hacol(alias='c_quantity').cql.Select().Where('$v=200'),
""" TRIADB-TriaClick Demo with Northwind Traders DataModel/DataSet HyperAtom Collection (HACOL) Operations (C) October 2019 By Athanassios I. Hatzis """ from triadb import MIS mis = MIS(debug=1) mis.connect_to_datastore(dbms='clickhouse', host='localhost', port=9000, user='******', password='******', database='TriaDB', trace=0) mis.connect_to_metastore(dbms='mariadb', host='localhost', port=3306, user='******', password='******', database='TRIADB', trace=0) # Set DataModel eng = mis.restart(500, reset=True) # Make multiple values selection for Customer Country mis.select('Brazil, Mexico, Argentina', In=True, alias='c_country')
""" TRIADB Modules Testing: creating an instance of top level management information system object (MIS) get_entities(), get_attributes(), get() methods of triadb.subsystems.DataModelSystem switching and setting DataModelSystem objects (C) October 2019 By Athanassios I. Hatzis """ from triadb import MIS mis = MIS(debug=1) mis.connect_to_datastore(dbms='clickhouse', host='localhost', port=9000, user='******', password='******', database='TriaDB', trace=0) mis.connect_to_metastore(dbms='mariadb', host='localhost', port=3306, user='******', password='******', database='TRIADB', trace=0) # Get an overview of the DataModelSystem mis.get(what='models') # Initialize MIS with a data model datmodel = mis.set_dms(alias='SPC') print(mis) print(datmodel, '\n', mis.dms) # General Overview datmodel.get(what='overview') # Data Model Overview datmodel.get() # Entities and Attributes datmodel.get_entities() datmodel.get_attributes()