galaxy.model.orm package

galaxy.model.orm - ORM-related functionality


galaxy.model.orm.engine_factory module

galaxy.model.orm.engine_factory.build_engine(url, engine_options=None, database_query_profiling_proxy=False, trace_logger=None, slow_query_log_threshold=0, thread_local_log=None, log_query_counts=False)[source] module

Return a new datetime representing UTC day and time.

galaxy.model.orm.scripts module

Code to support database helper scripts (,, etc…).

galaxy.model.orm.scripts.get_config(argv, use_argparse=True, cwd=None)[source]

Read sys.argv and parse out repository of migrations and database url.

>>> import os
>>> from configparser import ConfigParser
>>> from shutil import rmtree
>>> from tempfile import mkdtemp
>>> config_dir = mkdtemp()
>>> os.makedirs(os.path.join(config_dir, 'config'))
>>> def write_ini(path, property, value):
...     p = ConfigParser()
...     p.add_section('app:main')
...     p.set('app:main', property, value)
...     with open(os.path.join(config_dir, 'config', path), 'w') as f: p.write(f)
>>> write_ini('tool_shed.ini', 'database_connection', 'sqlite:///pg/testdb1')
>>> config = get_config(['', 'tool_shed'], cwd=config_dir)
>>> config['repo'].endswith('tool_shed/webapp/model/migrate')
>>> config['db_url']
>>> write_ini('galaxy.ini', 'data_dir', '/moo')
>>> config = get_config([''], cwd=config_dir)
>>> uri_with_env = os.getenv("GALAXY_TEST_DBURI", "sqlite:////moo/universe.sqlite?isolation_level=IMMEDIATE")
>>> config['db_url'] == uri_with_env
>>> rmtree(config_dir)

galaxy.model.orm.util module

galaxy.model.orm.util.add_object_to_object_session(object, object_with_session)[source]

Explicitly add object to the session. Addresses SQLAlchemy 2.0 compatibility issue:

This function preserves SQLAlchemy’s pre-2.0 logic and should be used when:

  1. foo and bar are model instances, that are associated (via SQLAlchemy’s relationship), AND

  2. bar is assigned to foo’s bar relationship (e.g. = bar), AND

  3. bar is in a session and foo is not, AND

  4. foo is implicitly added to bar’s session upon assignment(2), as indicated by a RemovedIn20Warning specifying that the ‘“foo” object is being merged into a Session along the backref cascade path…’

galaxy.model.orm.util.add_object_to_session(object, session)[source]

Explicitly add object to the session.