Created
June 7, 2020 22:57
-
-
Save cmabastar/f4a1c8fd478e7ee713db633b22d5b548 to your computer and use it in GitHub Desktop.
Sqalchemy + Alembic + Postgres Unlogged Table Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
op.create_table( | |
"unlogged_table", | |
sa.Column("id", sa.BigInteger(), nullable=False), | |
sa.PrimaryKeyConstraint("id", name=op.f("pk_unlogged_table")), | |
prefixes=["UNLOGGED"], | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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