You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the GitHub search to find a similar issue and didn't find it.
I searched the SQLModel documentation, with the integrated search.
I already searched in Google "How to X in SQLModel" and didn't find any information.
I already read and followed all the tutorial in the docs and didn't find an answer.
I already checked if it is not related to SQLModel but to Pydantic.
I already checked if it is not related to SQLModel but to SQLAlchemy.
Commit to Help
I commit to help with one of those options 👆
Example Code
fromtypingimportOptionalfromsqlmodelimportField, SQLModel# Data ModelsclassHeroCreate(SQLModel):
""" Data Model for Hero Creation """name: strsecret_name: strage: Optional[int] =NoneclassHeroRead(HeroCreate):
""" Data Model for Hero Read """id: intclassHeroUpdate(SQLModel):
""" Data Model for Hero Update """name: Optional[str] =Nonesecret_name: Optional[str] =Noneage: Optional[int] =None# Table ModelsclassHero(HeroCreate, table=True):
""" Table Model for Hero """id: Optional[int] =Field(default=None, primary_key=True)
Description
Create a Hero Model
Save it to the database using SQLModel.metadata.create_all(engine)
The database has an index for every field.
The default option should be no index, if not specified explicitly.
Operating System
Linux
Operating System Details
Kernel version: 5.14.14-arch1-1
SQLModel Version
0.0.4
Python Version
3.9.7
Additional Context
The output from the terminal when echo=True is shown below.
2021-11-06 15:45:40,513 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2021-11-06 15:45:40,513 INFO sqlalchemy.engine.Engine PRAGMA main.table_info("user")
2021-11-06 15:45:40,513 INFO sqlalchemy.engine.Engine [raw sql] ()
2021-11-06 15:45:40,514 INFO sqlalchemy.engine.Engine PRAGMA temp.table_info("user")
2021-11-06 15:45:40,514 INFO sqlalchemy.engine.Engine [raw sql] ()
2021-11-06 15:45:40,515 INFO sqlalchemy.engine.Engine PRAGMA main.table_info("hero")
2021-11-06 15:45:40,515 INFO sqlalchemy.engine.Engine [raw sql] ()
2021-11-06 15:45:40,515 INFO sqlalchemy.engine.Engine PRAGMA temp.table_info("hero")
2021-11-06 15:45:40,515 INFO sqlalchemy.engine.Engine [raw sql] ()
2021-11-06 15:45:40,517 INFO sqlalchemy.engine.Engine
CREATE TABLE user (
username VARCHAR NOT NULL,
email VARCHAR,
full_name VARCHAR NOT NULL,
id INTEGER,
hashed_password VARCHAR NOT NULL,
PRIMARY KEY (id)
)
2021-11-06 15:45:40,517 INFO sqlalchemy.engine.Engine [no key 0.00026s] ()
2021-11-06 15:45:40,601 INFO sqlalchemy.engine.Engine CREATE INDEX ix_user_email ON user (email)
2021-11-06 15:45:40,601 INFO sqlalchemy.engine.Engine [no key 0.00030s] ()
2021-11-06 15:45:40,693 INFO sqlalchemy.engine.Engine CREATE INDEX ix_user_full_name ON user (full_name)
2021-11-06 15:45:40,693 INFO sqlalchemy.engine.Engine [no key 0.00037s] ()
2021-11-06 15:45:40,783 INFO sqlalchemy.engine.Engine CREATE INDEX ix_user_id ON user (id)
2021-11-06 15:45:40,783 INFO sqlalchemy.engine.Engine [no key 0.00049s] ()
2021-11-06 15:45:40,871 INFO sqlalchemy.engine.Engine CREATE INDEX ix_user_username ON user (username)
2021-11-06 15:45:40,872 INFO sqlalchemy.engine.Engine [no key 0.00035s] ()
2021-11-06 15:45:40,961 INFO sqlalchemy.engine.Engine CREATE INDEX ix_user_hashed_password ON user (hashed_password)
2021-11-06 15:45:40,961 INFO sqlalchemy.engine.Engine [no key 0.00029s] ()
2021-11-06 15:45:41,040 INFO sqlalchemy.engine.Engine
CREATE TABLE hero (
name VARCHAR NOT NULL,
secret_name VARCHAR NOT NULL,
age INTEGER,
id INTEGER,
PRIMARY KEY (id)
)
2021-11-06 15:45:41,040 INFO sqlalchemy.engine.Engine [no key 0.00029s] ()
2021-11-06 15:45:41,151 INFO sqlalchemy.engine.Engine CREATE INDEX ix_hero_secret_name ON hero (secret_name)
2021-11-06 15:45:41,151 INFO sqlalchemy.engine.Engine [no key 0.00029s] ()
2021-11-06 15:45:41,263 INFO sqlalchemy.engine.Engine CREATE INDEX ix_hero_age ON hero (age)
2021-11-06 15:45:41,263 INFO sqlalchemy.engine.Engine [no key 0.00028s] ()
2021-11-06 15:45:41,375 INFO sqlalchemy.engine.Engine CREATE INDEX ix_hero_id ON hero (id)
2021-11-06 15:45:41,375 INFO sqlalchemy.engine.Engine [no key 0.00050s] ()
2021-11-06 15:45:41,487 INFO sqlalchemy.engine.Engine CREATE INDEX ix_hero_name ON hero (name)
2021-11-06 15:45:41,487 INFO sqlalchemy.engine.Engine [no key 0.00050s] ()
2021-11-06 15:45:41,597 INFO sqlalchemy.engine.Engine COMMIT
The text was updated successfully, but these errors were encountered:
First Check
Commit to Help
Example Code
Description
SQLModel.metadata.create_all(engine)
The default option should be no index, if not specified explicitly.
Operating System
Linux
Operating System Details
Kernel version: 5.14.14-arch1-1
SQLModel Version
0.0.4
Python Version
3.9.7
Additional Context
The output from the terminal when
echo=True
is shown below.The text was updated successfully, but these errors were encountered: