diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2019-08-07 03:09:30 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2019-08-07 03:09:30 +0000 |
commit | 6a622c636ca5bc55d96b92652fd43b914a77645c (patch) | |
tree | 4d4abbeab5f5b9d1c348d6aff849968df4e09479 /test/ext/test_horizontal_shard.py | |
parent | d45bd29918e217662ea2c0ee44608b0bbf0d4a06 (diff) | |
parent | 00b5c10846e800304caa86549ab9da373b42fa5d (diff) | |
download | sqlalchemy-6a622c636ca5bc55d96b92652fd43b914a77645c.tar.gz |
Merge "Modernize internal reflection"
Diffstat (limited to 'test/ext/test_horizontal_shard.py')
-rw-r--r-- | test/ext/test_horizontal_shard.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/ext/test_horizontal_shard.py b/test/ext/test_horizontal_shard.py index 838590f5b..6ea124268 100644 --- a/test/ext/test_horizontal_shard.py +++ b/test/ext/test_horizontal_shard.py @@ -437,6 +437,49 @@ class DistinctEngineShardTest(ShardTest, fixtures.TestBase): class AttachedFileShardTest(ShardTest, fixtures.TestBase): + """Use modern schema conventions along with SQLite ATTACH.""" + + schema = "changeme" + + def _init_dbs(self): + e = testing_engine("sqlite://") + with e.connect() as conn: + for i in range(1, 5): + conn.execute( + 'ATTACH DATABASE "shard%s_%s.db" AS shard%s' + % (i, provision.FOLLOWER_IDENT, i) + ) + + db1 = e.execution_options(schema_translate_map={"changeme": "shard1"}) + db2 = e.execution_options(schema_translate_map={"changeme": "shard2"}) + db3 = e.execution_options(schema_translate_map={"changeme": "shard3"}) + db4 = e.execution_options(schema_translate_map={"changeme": "shard4"}) + + self.engine = e + return db1, db2, db3, db4 + + def teardown(self): + clear_mappers() + + self.engine.connect().invalidate() + for i in range(1, 5): + os.remove("shard%d_%s.db" % (i, provision.FOLLOWER_IDENT)) + + +class TableNameConventionShardTest(ShardTest, fixtures.TestBase): + """This fixture uses a single SQLite database along with a table naming + convention to achieve sharding. Event hooks are used to rewrite SQL + statements. + + This used to be called "AttachedFileShardTest" but I didn't see any + ATTACH going on. + + The approach taken by this test is awkward and I wouldn't recommend using + this pattern in a real situation. I'm not sure of the history of this test + but it likely predates when we knew how to use real ATTACH in SQLite. + + """ + schema = "changeme" def _init_dbs(self): |