PageRenderTime 43ms CodeModel.GetById 39ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/scripts/manage_db.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 31 lines | 19 code | 9 blank | 3 comment | 1 complexity | 79b28146049e5e20c332a25c444e9c19 MD5 | raw file
 1""" This script parses Galaxy or Tool Shed config file for database connection
 2and then delegates to sqlalchemy_migrate shell main function in
 3migrate.versioning.shell. """
 4import sys
 5import os.path
 6
 7new_path = [ os.path.join( os.getcwd(), "lib" ) ]
 8new_path.extend( sys.path[1:] )  # remove scripts/ from the path
 9sys.path = new_path
10
11from galaxy import eggs
12
13eggs.require( "decorator" )
14eggs.require( "Tempita" )
15eggs.require( "SQLAlchemy" )
16eggs.require( "sqlalchemy_migrate" )
17
18from migrate.versioning.shell import main
19
20from galaxy.model.orm.scripts import get_config
21
22
23def invoke_migrate_main():
24    config = get_config( sys.argv )
25    db_url = config['db_url']
26    repo = config['repo']
27
28    main( repository=repo, url=db_url )
29
30if __name__ == "__main__":
31    invoke_migrate_main()