Skip to content
Discussion options

You must be logged in to vote

@jochman , Try this:

from sqlmodel import Field, SQLModel, create_engine
from sqlalchemy.schema import CreateTable

class Hero(SQLModel, table=True):
    id: int = Field(default=None, primary_key=True)
    name: str
    secret_name: str

sqlite_file_name = "database.db"
sqlite_url = f"sqlite:///{sqlite_file_name}"

engine = create_engine(sqlite_url, echo=True)

print(CreateTable(Hero.__table__).compile(engine))

found it here: https://stackoverflow.com/questions/2128717/sqlalchemy-printing-raw-sql-from-create

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
2 participants