Last active
February 16, 2023 14:39
-
-
Save giuliano-macedo/9fef9352395ccc4dc0304c23a5cdd3a9 to your computer and use it in GitHub Desktop.
sqlalchemy createtable with cascade (with type hints), original answer: https://stackoverflow.com/a/38679457/5133524
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
from sqlalchemy.schema import DropTable | |
from sqlalchemy.ext.compiler import compiles | |
from sqlalchemy.dialects.postgresql.base import PGDDLCompiler | |
from typing import Any | |
@compiles(DropTable, "postgresql") | |
def _compile_drop_table(element: DropTable, compiler: PGDDLCompiler, **kwargs: Any) -> str: | |
return compiler.visit_drop_table(element) + " CASCADE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment