/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
  2. and then delegates to sqlalchemy_migrate shell main function in
  3. migrate.versioning.shell. """
  4. import sys
  5. import os.path
  6. new_path = [ os.path.join( os.getcwd(), "lib" ) ]
  7. new_path.extend( sys.path[1:] ) # remove scripts/ from the path
  8. sys.path = new_path
  9. from galaxy import eggs
  10. eggs.require( "decorator" )
  11. eggs.require( "Tempita" )
  12. eggs.require( "SQLAlchemy" )
  13. eggs.require( "sqlalchemy_migrate" )
  14. from migrate.versioning.shell import main
  15. from galaxy.model.orm.scripts import get_config
  16. def invoke_migrate_main():
  17. config = get_config( sys.argv )
  18. db_url = config['db_url']
  19. repo = config['repo']
  20. main( repository=repo, url=db_url )
  21. if __name__ == "__main__":
  22. invoke_migrate_main()