Skip to content

Instantly share code, notes, and snippets.

@cmabastar
Created June 7, 2020 22:57
Show Gist options
  • Save cmabastar/f4a1c8fd478e7ee713db633b22d5b548 to your computer and use it in GitHub Desktop.
Save cmabastar/f4a1c8fd478e7ee713db633b22d5b548 to your computer and use it in GitHub Desktop.
Sqalchemy + Alembic + Postgres Unlogged Table Example
op.create_table(
"unlogged_table",
sa.Column("id", sa.BigInteger(), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_unlogged_table")),
prefixes=["UNLOGGED"],
)
class UnloggedTable(Model):
"""Table example for unlogged model. We use TEMPORARY/UNLOGGED table to minimize WAL writeups,
In addition, this table won't be replicated to the cluster. This will also improve write speed.
"""
__tablename__ = "unlogged_table"
__table_args__ = {"prefixes": ["UNLOGGED"]}
id = Column(db.BigInteger(), primary_key=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment