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
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):
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,
),
)
+ def test_create_table_without_rowid(self):
+ m = MetaData()
+ tbl = Table(
+ "atable", m, Column("id", Integer), sqlite_with_rowid=False
+ )
+ self.assert_compile(
+ schema.CreateTable(tbl),
+ "CREATE TABLE atable (id INTEGER) WITHOUT ROWID",
+ )
+
class OnConflictDDLTest(fixtures.TestBase, AssertsCompiledSQL):