SPIKE: Generate SQL models from fields in pydantic models
See original GitHub issueOverview
Currently, we manually define the SQL models for the caching system. Look into automatically generating the table columns from the fields of pydantic models that are associated with these caching tables.
Specification
This is the general idea, but obviously not the implementation
class ContractEvents(SQLModel):
id: Optional[int]
event: str
...
class ContractEventsCache(ContractEvents, table=true):
some_fk_field: some_data_type = Field(some_fk, ...)
Dependencies
sqlmodel -> https://sqlmodel.tiangolo.com/
Issue Analytics
- State:
- Created a year ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
FastAPI and Pydantic - Intro - SQLModel
In this group of chapters we will see how to combine SQLModel table models representing tables in the SQL database as all the...
Read more >[QUESTION] How to bridge Pydantic models with SQLAlchemy?
So, Pydantic and SQLAlchemy are separated. Pydantic is used for documentation, validation, and data serialization. SQLAlchemy for SQL ORM stuff.
Read more >Code Generation - pydantic
The datamodel-code-generator project is a library and command-line utility to generate pydantic models from just about any data source, ...
Read more >How to generate Pydantic & SQLAlchemy/GinoORM models ...
This article demonstrates how to generate ORM & Pydantic models from DDL files with O!MyModels library. With one command or 1 line of...
Read more >Models - pydantic
Creating models without validation; __fields_set__: Set of names of fields which were set ... class SQLModel(BaseModel): __tablename__ = 'my_table' id = sa.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@fubuloubu, @banteg I am using
sqlmodel
in a RestAPI service that I am building out. And while it has some pretty interesting features, it is not an end all be all solution. I think it would be a mistake to integrate this into Ape. This spike will remain open, I am still attempting to generate SQL fields using the pydantic models, just not with sqlmodel.alembic would probably be the move here @fubuloubu