summaryrefslogtreecommitdiff
path: root/test/ext/test_horizontal_shard.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-08-02 12:34:16 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-08-06 18:05:45 -0400
commit00b5c10846e800304caa86549ab9da373b42fa5d (patch)
tree0832401deebeaad5fd6edc99158d0b10f958e716 /test/ext/test_horizontal_shard.py
parente091775f1c4c817093e9a936a3abc79b5e311f93 (diff)
downloadsqlalchemy-00b5c10846e800304caa86549ab9da373b42fa5d.tar.gz
Modernize internal reflection
- Deprecated remaining engine-level introspection and utility methods including :meth:`.Engine.run_callable`, :meth:`.Engine.transaction`, :meth:`.Engine.table_names`, :meth:`.Engine.has_table`. The utility methods are superseded by modern context-manager patterns, and the table introspection tasks are suited by the :class:`.Inspector` object. - The internal dialect method ``Dialect.reflecttable`` has been removed. A review of third party dialects has not found any making use of this method, as it was already documented as one that should not be used by external dialects. Additionally, the private ``Engine._run_visitor`` method is also removed. - The long-deprecated ``Inspector.get_table_names.order_by`` parameter has been removed. - The :paramref:`.Table.autoload_with` parameter now accepts an :class:`.Inspector` object directly, as well as any :class:`.Engine` or :class:`.Connection` as was the case before. Fixes: #4755 Change-Id: Iec3a8b0f3e298ba87d532b16fac1e1132f464e21
Diffstat (limited to 'test/ext/test_horizontal_shard.py')
-rw-r--r--test/ext/test_horizontal_shard.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/ext/test_horizontal_shard.py b/test/ext/test_horizontal_shard.py
index affd7112c..0f3bc8f37 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):