summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/declarative.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-01-11 16:35:34 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-01-11 16:35:34 -0500
commitf54a3b255a5f93b44b7530d89f6d17e3938150f4 (patch)
treedc3f2c2fd6a59f6a3cc5b37ac40a64bf9ab9e00b /lib/sqlalchemy/ext/declarative.py
parentf2568b9bdedd12427aaaed393c68dcf20691ea11 (diff)
downloadsqlalchemy-f54a3b255a5f93b44b7530d89f6d17e3938150f4.tar.gz
add examples for multi metadata under __abstract__, custom vertical partitioning
Diffstat (limited to 'lib/sqlalchemy/ext/declarative.py')
-rwxr-xr-xlib/sqlalchemy/ext/declarative.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py
index 61ec53343..bd655a721 100755
--- a/lib/sqlalchemy/ext/declarative.py
+++ b/lib/sqlalchemy/ext/declarative.py
@@ -906,6 +906,7 @@ has finished::
""
# do something with mappings
+.. _declarative_abstract:
``__abstract__``
~~~~~~~~~~~~~~~~~~~
@@ -927,6 +928,26 @@ just from the special class::
class MyMappedClass(SomeAbstractBase):
""
+
+One possible use of ``__abstract__`` is to use a distinct :class:`.MetaData` for different
+bases::
+
+ Base = declarative_base()
+
+ class DefaultBase(Base):
+ __abstract__ = True
+ metadata = MetaData()
+
+ class OtherBase(Base):
+ __abstract__ = True
+ metadata = MetaData()
+
+Above, classes which inherit from ``DefaultBase`` will use one :class:`.MetaData` as the
+registry of tables, and those which inherit from ``OtherBase`` will use a different one.
+The tables themselves can then be created perhaps within distinct databases::
+
+ DefaultBase.metadata.create_all(some_engine)
+ OtherBase.metadata_create_all(some_other_engine)
Class Constructor
=================