Choose which model to consider #1478
-
First Check
Commit to Help
Example Codefrom typing import Optional
from sqlmodel import Field, SQLModel, create_engine
class Hero(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
name: str
secret_name: str
age: Optional[int] = None
sqlite_file_name = "database.db"
sqlite_url = f"sqlite:///{sqlite_file_name}"
engine = create_engine(sqlite_url, echo=True)
SQLModel.metadata.create(engine, {Hero}) DescriptionInstead of using Wanted SolutionWhy is it useful?
SuggestionIt might be good to add a
I don't think so. It sure is handy. But as pointed out, it has its pitfalls too. Whether one uses the Thank you for this tool! Wanted CodeSQLModel.metadata.create(engine, {Hero}) AlternativesObviously, both the method name and the parameter (a set) could be adjusted, but the principle would be the same. Operating SystemWindows Operating System DetailsNo response SQLModel Version0.0.6 Python Version3.8.10 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@vincent-lg you can still use SQLAlchemy API with SQLModel.
|
Beta Was this translation helpful? Give feedback.
@vincent-lg you can still use SQLAlchemy API with SQLModel.
So you could do