def setUpClass(cls, force_foreign_keys=True): super().setUpClass(datasource_name=TARGET_NAMESPACE + '.' + get_unittest_tenant_name(), metadata=generate_ed_metadata(), use_metadata_from_db=False, resources_dir=None, force_foreign_keys=force_foreign_keys) super().setUpClass(datasource_name=PRODUCTION_NAMESPACE + '.' + get_unittest_tenant_name(), metadata=generate_ed_metadata(), use_metadata_from_db=False, resources_dir=None, force_foreign_keys=force_foreign_keys)
def create_sqlite(force_foreign_keys=True, use_metadata_from_db=False, echo=False, metadata=None, datasource_name=''): __engine = create_engine('sqlite:///:memory:', connect_args={ 'detect_types': sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES }, native_datetime=True, echo=echo) if force_foreign_keys: event.listen(__engine, 'connect', __fk_on) __metadata = metadata if __metadata is None: __metadata = generate_ed_metadata() # create tables from static metadata __metadata.create_all(bind=__engine, checkfirst=False) if use_metadata_from_db: # since we want to test db creation, read metadata from sqlite __metadata = MetaData() __metadata.reflect(bind=__engine) dbUtil = DbUtil(engine=__engine, metadata=__metadata) component.provideUtility(dbUtil, IDbUtil, name=datasource_name)
def create_sqlite(force_foreign_keys=True, use_metadata_from_db=False, echo=False, metadata=None, datasource_name=''): __engine = create_engine('sqlite:///:memory:', connect_args={'detect_types': sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES}, native_datetime=True, echo=echo) if force_foreign_keys: event.listen(__engine, 'connect', __fk_on) __metadata = metadata if __metadata is None: __metadata = generate_ed_metadata() # create tables from static metadata __metadata.create_all(bind=__engine, checkfirst=False) if use_metadata_from_db: # since we want to test db creation, read metadata from sqlite __metadata = MetaData() __metadata.reflect(bind=__engine) dbUtil = DbUtil(engine=__engine, metadata=__metadata) component.provideUtility(dbUtil, IDbUtil, name=datasource_name)
def generate_metadata(schema_name=None, bind=None): ''' Generates metadata for edware ''' return generate_ed_metadata(schema_name=schema_name, bind=bind)
print("Please specify --schema option") exit(-1) __URL = DBDRIVER + "://" + __user + ":" + __passwd + "@" + __host + "/" + __database print("DB Driver:" + DBDRIVER) print(" User:"******" Password:"******" Host:" + __host) print(" Database:" + __database) print(" Schema:" + __schema) print("####################") engine = create_engine(__URL, echo=True) connection = engine.connect() if __action == 'setup': connection.execute(CreateSchema(__schema)) if __metadata == 'edware': metadata = generate_ed_metadata(schema_name=__schema, bind=engine) connection.execute('CREATE SEQUENCE "' + __schema + '"."global_rec_seq"') else: metadata = generate_stats_metadata(schema_name=__schema, bind=engine) metadata.create_all(engine) elif __action == 'teardown': # metadata = generate_ed_metadata(schema_name=__schema, bind=engine) # metadata.drop_all(engine) try: connection.execute(DropSchema(__schema, cascade=True)) except: pass