#!/usr/bin/env python3 # import sys import os import os.path print(os.path.abspath(os.curdir)) print(__file__) module_path = os.path.abspath( os.path.join(os.path.dirname(__file__), "../src/modules") ) print(f"Add python module path: '{module_path}'") sys.path.insert(0, module_path) try: from itemsdb.log import info, warn, error, debug except Exception as i_e: e_msg = f"Fail to import itemsdb.log: {i_e}" print(e_msg, file=sys.stderr) raise Exception(e_msg) from itemsdb import * database_filename = os.getenv("ITEMSDB_DATABASE_NAME", "itemsdb_test.db") database_path_module = os.path.abspath( os.path.join(os.path.dirname(__file__), "../build", database_filename) ) database_path = os.getenv("ITEMSDB_DATABASE_PATH", database_path_module) database_table_prefix = os.getenv("ITEMSDB_DATABASE_TABLE_PREFIX", "test") database_pragmas = dict( journal_mode="wal", foreign_keys=1, ignore_check_constraints=0 ) success, db, e_msg = createDatabase( database_path, force=True, pragmas=database_pragmas ) if not success: error(e_msg) sys.exit(1) success, db, e_msg = createTables( db, itemsdb_models, prefix=database_table_prefix ) if not success: error(e_msg) sys.exit(2) item_name = "server" item_schema = dict(name=item_name, properties=[1, 2, 3, 4, 5]) success, item_type, e_msg = createItemType(db, item_name, item_schema) if not success: error(e_msg) sys.exit(3)