def create_tables(host, user, password, database): """ create a table """ print('Creating tables in test database') driver = PsqlGraphDriver(host, user, password, database) create_all(driver.engine)
def create_tables(host, user, password, database): """ create a table """ print("Creating tables in test database") engine = create_engine("postgres://{user}:{pwd}@{host}/{db}".format( user=user, host=host, pwd=password, db=database)) create_all(engine) versioned_nodes.Base.metadata.create_all(engine)
def create_tables(host, user, password, database): """ create a table """ print('Creating tables in test database') engine = create_engine("postgres://{user}:{pwd}@{host}/{db}".format( user=user, host=host, pwd=password, db=database)) create_all(engine) versioned_nodes.Base.metadata.create_all(engine)
def create_tables(engine): """ create a table """ create_all(engine) models.versioned_nodes.Base.metadata.create_all(engine) models.submission.Base.metadata.create_all(engine) models.redaction.Base.metadata.create_all(engine) models.qcreport.Base.metadata.create_all(engine) models.misc.Base.metadata.create_all(engine)
def create_tables(engine, namespace=None): """ create a table """ base = psqlgraph.base.ORMBase if namespace: base = ext.get_orm_base(namespace) create_all(engine, base) if not namespace: # add ng models only to main graph create_ng_tables(engine)
def create_graph_tables(engine, timeout): """ create a table """ logger.info('Creating tables (timeout: %d)', timeout) connection = engine.connect() trans = connection.begin() logger.info("Setting lock_timeout to %d", timeout) timeout_str = '{}s'.format(int(timeout+1)) connection.execute("SET LOCAL lock_timeout = %s;", timeout_str) create_all(connection) trans.commit()
def create_graph_tables(engine, timeout, namespace=None): """ create a table """ logger.info('Creating tables (timeout: %d)', timeout) connection = engine.connect() trans = connection.begin() logger.info("Setting lock_timeout to %d", timeout) timeout_str = '{}s'.format(int(timeout + 1)) connection.execute("SET LOCAL lock_timeout = %s;", timeout_str) orm_base = ext.get_orm_base(namespace) if namespace else ORMBase create_all(connection, base=orm_base) trans.commit()
def db(graph_models): models, _ = graph_models db_driver = psqlgraph.PsqlGraphDriver(host="localhost", user="******", password="******", database="gexplorer") # precautionary drop_all(db_driver.engine) psqlgraph.create_all(db_driver.engine) add_project(db_driver, models) yield db_driver drop_all(db_driver.engine)
def _run(connection): create_all(connection) # migrate indexes exist_index_uniqueness = dict( iter( connection.execute("SELECT i.relname, ix.indisunique " "FROM pg_class i, pg_index ix " "WHERE i.oid = ix.indexrelid"))) for cls in Node.__subclasses__() + Edge.__subclasses__(): for index in cls.__table__.indexes: uniq = exist_index_uniqueness.get(index.name, None) if uniq is None: # create the missing index index.create(connection) elif index.unique != uniq: # recreate indexes whose uniqueness changed index.drop(connection) index.create(connection)
def create_graph_tables(engine, timeout): """ create a table """ print('Creating tables in database') connection = engine.connect() trans = connection.begin() try: connection.execute(text("SET LOCAL lock_timeout = :timeout ;"), timeout='{}s'.format(timeout*1000)) create_all(connection) trans.commit() except Exception as e: trans.rollback() if 'timeout' in str(e): print 'Attempt timed out', str(e) else: raise
def create_tables(host, port, user, password, database, use_ssl=False): """ create a table """ print("Creating tables in test database") # added for Postgresql SSL connect_args = {} if use_ssl: connect_args["sslmode"] = "require" engine = create_engine( _get_connection_string(user=user, password=password, host=host, port=port, database=database), connect_args=connect_args, ) create_all(engine) versioned_nodes.Base.metadata.create_all(engine)
def _create_tables(driver, create_all, timeout): """ create tables Args: driver: sqlalchemy driver create_all (function): create_all function that creates all tables timeout (int): timeout for transaction Returns: None """ logger.info("Creating tables (timeout: %d)", timeout) with driver.session_scope() as session: connection = session.connection() logger.info("Setting lock_timeout to %d", timeout) timeout_str = "{}s".format(int(timeout + 1)) connection.execute("SET LOCAL lock_timeout = %s;", timeout_str) create_all(connection) update_version(driver, session)
def _add_tables(self): create_all(self.g.engine)