engines.py 794 B

12345678910111213141516171819202122232425262728
  1. # testing/engines.py
  2. # Copyright (C) 2005-2017 the SQLAlchemy authors and contributors
  3. # <see AUTHORS file>
  4. #
  5. # This module is part of SQLAlchemy and is released under
  6. # the MIT License: http://www.opensource.org/licenses/mit-license.php
  7. """NOTE: copied/adapted from SQLAlchemy master for backwards compatibility;
  8. this should be removable when Alembic targets SQLAlchemy 1.0.0.
  9. """
  10. from __future__ import absolute_import
  11. from . import config
  12. def testing_engine(url=None, options=None):
  13. """Produce an engine configured by --options with optional overrides."""
  14. from sqlalchemy import create_engine
  15. url = url or config.db.url
  16. if options is None:
  17. options = config.db_opts
  18. engine = create_engine(url, **options)
  19. return engine