diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-09-28 17:35:16 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-09-28 17:48:55 -0400 |
commit | 5bb2536cc57c55c7d8c5901b5b622d18a9a6c646 (patch) | |
tree | 97f8b994aaae0d6fbf6dc2e500ff8b2a2b64c0d6 /lib/sqlalchemy/testing/provision.py | |
parent | e4d445c6f56b2962b2b8e649575f70f5cb7fdc1f (diff) | |
download | sqlalchemy-5bb2536cc57c55c7d8c5901b5b622d18a9a6c646.tar.gz |
- limit the search for schemas to not include "temp", which is sort of an implicit schema
- repair the CREATE INDEX ddl for schemas
- update provisioning to include support for setting up ATTACH DATABASE up front
for the test_schema; enable "schemas" testing for SQLite
- changelog / migration notes for new SQLite schema support
- include the "schema" as the "remote_schema" when we reflect SQLite FKs
Diffstat (limited to 'lib/sqlalchemy/testing/provision.py')
-rw-r--r-- | lib/sqlalchemy/testing/provision.py | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/lib/sqlalchemy/testing/provision.py b/lib/sqlalchemy/testing/provision.py index 77527571b..2d7fe0a3f 100644 --- a/lib/sqlalchemy/testing/provision.py +++ b/lib/sqlalchemy/testing/provision.py @@ -2,7 +2,7 @@ from sqlalchemy.engine import url as sa_url from sqlalchemy import text from sqlalchemy.util import compat from . import config, engines - +import os FOLLOWER_IDENT = None @@ -52,6 +52,7 @@ def setup_config(db_url, options, file_config, follower_ident): db_opts = {} _update_db_opts(db_url, db_opts) eng = engines.testing_engine(db_url, db_opts) + _post_configure_engine(db_url, eng, follower_ident) eng.connect().close() cfg = config.Config.register(eng, db_opts, options, file_config) if follower_ident: @@ -106,6 +107,11 @@ def _configure_follower(cfg, ident): @register.init +def _post_configure_engine(url, engine): + pass + + +@register.init def _follower_url_from_main(url, ident): url = sa_url.make_url(url) url.database = ident @@ -126,6 +132,23 @@ def _sqlite_follower_url_from_main(url, ident): return sa_url.make_url("sqlite:///%s.db" % ident) +@_post_configure_engine.for_db("sqlite") +def _sqlite_post_configure_engine(url, engine, follower_ident): + from sqlalchemy import event + + @event.listens_for(engine, "connect") + def connect(dbapi_connection, connection_record): + # use file DBs in all cases, memory acts kind of strangely + # as an attached + if not follower_ident: + dbapi_connection.execute( + 'ATTACH DATABASE "test_schema.db" AS test_schema') + else: + dbapi_connection.execute( + 'ATTACH DATABASE "%s_test_schema.db" AS test_schema' + % follower_ident) + + @_create_db.for_db("postgresql") def _pg_create_db(cfg, eng, ident): with eng.connect().execution_options( @@ -176,8 +199,10 @@ def _pg_drop_db(cfg, eng, ident): @_drop_db.for_db("sqlite") def _sqlite_drop_db(cfg, eng, ident): - pass - #os.remove("%s.db" % ident) + if ident: + os.remove("%s_test_schema.db" % ident) + else: + os.remove("%s.db" % ident) @_drop_db.for_db("mysql") |