create_pickle_file.py 734 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/python
  2. # recreate the pickle file db-metadata-*.pkl that needs to be updated
  3. # after a database upgrade
  4. from sqlalchemy import create_engine, __version__
  5. import pickle
  6. import sys
  7. from os.path import abspath, dirname
  8. DAK_TEST_DIR = dirname(abspath(__file__))
  9. DAK_ROOT_DIR = dirname(DAK_TEST_DIR)
  10. if DAK_ROOT_DIR not in sys.path:
  11. sys.path.insert(0, DAK_ROOT_DIR)
  12. from daklib.dbconn import DBConn
  13. pickle_filename = '%s/fixtures/db-metadata-%s.pkl' % (DAK_TEST_DIR, __version__)
  14. pickle_file = open(pickle_filename, 'w')
  15. metadata = DBConn().db_meta
  16. pickle.dump(metadata, pickle_file)
  17. pickle.dump(metadata.ddl_listeners, pickle_file)
  18. pickle_file.close()
  19. print "File %s has been updated successfully." % pickle_filename