def init(file_path, url, engine_options=None, create_tables=False, map_install_models=False, database_query_profiling_proxy=False, object_store=None, trace_logger=None, use_pbkdf2=True, slow_query_log_threshold=0, thread_local_log: Optional[local] = None, log_query_counts=False) -> GalaxyModelMapping: """Connect mappings to the database""" if engine_options is None: engine_options = {} # Connect dataset to the file path model.Dataset.file_path = file_path # Connect dataset to object store model.Dataset.object_store = object_store # Use PBKDF2 password hashing? model.User.use_pbkdf2 = use_pbkdf2 # Load the appropriate db module engine = build_engine(url, engine_options, database_query_profiling_proxy, trace_logger, slow_query_log_threshold, thread_local_log=thread_local_log, log_query_counts=log_query_counts) # Connect the metadata to the database. metadata.bind = engine model_modules = [model] if map_install_models: import galaxy.model.tool_shed_install.mapping # noqa: F401 from galaxy.model import tool_shed_install galaxy.model.tool_shed_install.mapping.init( url=url, engine_options=engine_options, create_tables=create_tables) model_modules.append(tool_shed_install) result = GalaxyModelMapping(model_modules, engine=engine) # Create tables if needed if create_tables: metadata.create_all() install_timestamp_triggers(engine) install_views(engine) result.create_tables = create_tables # load local galaxy security policy result.security_agent = GalaxyRBACAgent(result) result.thread_local_log = thread_local_log return result
def init(url, engine_options=None, create_tables=False): """Connect mappings to the database""" # Load the appropriate db module engine_options = engine_options or {} engine = build_engine(url, engine_options) result = ModelMapping([install_model], engine=engine) # Create tables if needed if create_tables: metadata.create_all(bind=engine) # metadata.engine.commit() result.create_tables = create_tables # load local galaxy security policy return result
def init( url, engine_options={}, create_tables=False ): """Connect mappings to the database""" # Load the appropriate db module engine = build_engine( url, engine_options ) # Connect the metadata to the database. metadata.bind = engine result = ModelMapping( [ install_model ], engine=engine ) # Create tables if needed if create_tables: metadata.create_all() # metadata.engine.commit() result.create_tables = create_tables #load local galaxy security policy return result
def init(file_path, url, engine_options={}, create_tables=False): """Connect mappings to the database""" # Create the database engine engine = build_engine(url, engine_options) # Connect the metadata to the database. metadata.bind = engine result = ModelMapping([tool_shed.webapp.model], engine=engine) if create_tables: metadata.create_all() result.create_tables = create_tables # Load local tool shed security policy result.security_agent = CommunityRBACAgent(result) result.shed_counter = shed_statistics.ShedCounter(result) return result
def init(file_path, url, engine_options={}, create_tables=False): """Connect mappings to the database""" # Create the database engine engine = build_engine(url, engine_options) # Connect the metadata to the database. metadata.bind = engine result = ModelMapping([galaxy.webapps.tool_shed.model], engine=engine) if create_tables: metadata.create_all() result.create_tables = create_tables # Load local tool shed security policy result.security_agent = CommunityRBACAgent(result) result.shed_counter = shed_statistics.ShedCounter(result) result.hgweb_config_manager = galaxy.webapps.tool_shed.util.hgweb_config.HgWebConfigManager() return result
def _db(self): '''Initialize the database file.''' dialect_to_egg = dict(sqlite='pysqlite>=2', postgres='psycopg2', mysql='MySQL_python') dialect = (self.dburi.split(':', 1))[0] try: egg = dialect_to_egg[dialect] try: pkg_resources.require(egg) log.debug('Lodaded egg %s for %s dialect' % (egg, dialect)) except Exception: # If the module is in the path elsewhere # (i.e. non-egg), it'll still load. log.debug('Egg not found, attempting %s anyway' % (dialect)) except KeyError: # Let this go, it could possibly work with db's we don't support. log.debug('Unknown SQLAlchemy database dialect: %s' % dialect) # Initialize the database connection. engine = build_engine(self.dburi, dict()) MetaData(bind=engine) Session = scoped_session( sessionmaker(bind=engine, autoflush=False, autocommit=True)) self.db = Session