summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-01-12 15:57:46 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2017-01-12 15:57:46 -0500
commit0460bc79d9986132646049d8167bd5dbe3388a65 (patch)
tree91f5277cf7c2cdeffad8939cad371e671abefa9e /lib/sqlalchemy/dialects/postgresql/base.py
parent073506bc555b2f3339e30d18e61a958e257009ac (diff)
downloadsqlalchemy-0460bc79d9986132646049d8167bd5dbe3388a65.tar.gz
- document how to use autocommit isolation level for CONCURRENTLY,
fixes #3887 Change-Id: I6d1a13b7bb4169204105c7a100d17cfed3ded9d1
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 8bf6e10c1..b436b934f 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -644,6 +644,25 @@ a connection-less dialect, it will emit::
of PostgreSQL is detected on the connection (or for a connection-less
dialect).
+When using CONCURRENTLY, the Postgresql database requires that the statement
+be invoked outside of a transaction block. The Python DBAPI enforces that
+even for a single statement, a transaction is present, so to use this
+construct, the DBAPI's "autocommit" mode must be used::
+
+ metadata = MetaData()
+ table = Table(
+ "foo", metadata,
+ Column("id", String))
+ index = Index(
+ "foo_idx", table.c.id, postgresql_concurrently=True)
+
+ with engine.connect() as conn:
+ with conn.execution_options(isolation_level='AUTOCOMMIT'):
+ table.create(conn)
+
+.. seealso::
+
+ :ref:`postgresql_isolation_level`
.. _postgresql_index_reflection: