summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorVsevolod Solovyov <vsevolod.solovyov@gmail.com>2018-03-15 09:00:47 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2018-03-30 12:18:09 -0400
commit0174d698a8ed155b51cc44c503b10bc67b16dfc9 (patch)
tree22d4870e735e032e9c258dddf2d0d54c23002bbe /lib/sqlalchemy
parent0fd508ad32a6f94653757a5ae10c1eae14e099fc (diff)
downloadsqlalchemy-0174d698a8ed155b51cc44c503b10bc67b16dfc9.tar.gz
Add support for declarative partitioning in PostgreSQL 10
Added support for "PARTITION BY" in Postgresql table definitions, using "postgresql_partition_by". Pull request courtesy Vsevolod Solovyov. Change-Id: Id74d6882d7193fae1e5fd44b6e12d6852866fcc4 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/430
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 5ae27a996..1dffe8db9 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -780,7 +780,14 @@ dialect in conjunction with the :class:`.Table` construct:
Table("some_table", metadata, ..., postgresql_inherits=("t1", "t2", ...))
-.. versionadded:: 1.0.0
+ .. versionadded:: 1.0.0
+
+* ``PARTITION BY``::
+
+ Table("some_table", metadata, ...,
+ postgresql_partition_by='LIST (part_column)')
+
+ .. versionadded:: 1.2.6
.. seealso::
@@ -1829,6 +1836,9 @@ class PGDDLCompiler(compiler.DDLCompiler):
', '.join(self.preparer.quote(name) for name in inherits) +
' )')
+ if pg_opts['partition_by']:
+ table_opts.append('\n PARTITION BY %s' % pg_opts['partition_by'])
+
if pg_opts['with_oids'] is True:
table_opts.append('\n WITH OIDS')
elif pg_opts['with_oids'] is False:
@@ -2166,6 +2176,7 @@ class PGDialect(default.DefaultDialect):
(schema.Table, {
"ignore_search_path": False,
"tablespace": None,
+ "partition_by": None,
"with_oids": None,
"on_commit": None,
"inherits": None