Replies: 1 comment
-
@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 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
I need to get the query text of creating this table - how do I do that without creating a new sqlalchemy object to replace this?
Operating System
Linux
Operating System Details
No response
SQLModel Version
0.0.14
Python Version
3.12.2
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions