summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/sqlite
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-11-09 15:56:15 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-11-09 15:56:15 +0000
commitb3f2f08f4870877d689b987747d7db5baa7aca75 (patch)
tree2b7fb2f5a8e8e0eb6d792c2afea50867846ae8a2 /lib/sqlalchemy/dialects/sqlite
parent89ddd0b8976ed695d239898a2a8e4ebf531537f2 (diff)
parent4b39b0f89dfd47dc9f5ba948e564c2afbbd44fef (diff)
downloadsqlalchemy-b3f2f08f4870877d689b987747d7db5baa7aca75.tar.gz
Merge "Support SQLite WITHOUT ROWID tables"
Diffstat (limited to 'lib/sqlalchemy/dialects/sqlite')
-rw-r--r--lib/sqlalchemy/dialects/sqlite/base.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py
index fc08b4b5e..404a215b6 100644
--- a/lib/sqlalchemy/dialects/sqlite/base.py
+++ b/lib/sqlalchemy/dialects/sqlite/base.py
@@ -789,6 +789,21 @@ or on a per-:class:`_engine.Engine` basis::
When using the per-:class:`_engine.Engine` execution option, note that
**Core and ORM queries that use UNION may not function properly**.
+SQLite-specific table options
+-----------------------------
+
+One option for CREATE TABLE is supported directly by the SQLite
+dialect in conjunction with the :class:`_schema.Table` construct:
+
+* ``WITHOUT ROWID``::
+
+ Table("some_table", metadata, ..., sqlite_with_rowid=False)
+
+.. seealso::
+
+ `SQLite CREATE TABLE options
+ <https://www.sqlite.org/lang_createtable.html>`_
+
""" # noqa
import datetime
@@ -1563,6 +1578,11 @@ class SQLiteDDLCompiler(compiler.DDLCompiler):
return text
+ def post_create_table(self, table):
+ if table.dialect_options["sqlite"]["with_rowid"] is False:
+ return "\n WITHOUT ROWID"
+ return ""
+
class SQLiteTypeCompiler(compiler.GenericTypeCompiler):
def visit_large_binary(self, type_, **kw):
@@ -1770,7 +1790,13 @@ class SQLiteDialect(default.DefaultDialect):
isolation_level = None
construct_arguments = [
- (sa_schema.Table, {"autoincrement": False}),
+ (
+ sa_schema.Table,
+ {
+ "autoincrement": False,
+ "with_rowid": True,
+ },
+ ),
(sa_schema.Index, {"where": None}),
(
sa_schema.Column,