Skip to content

difference between ormdantic and sqlmodel? #25

Answered by iron3oxide
0xsirsaif asked this question in Q&A
Discussion options

You must be logged in to vote

This should probably be a discussion instead, but I'll give it a try (disclaimer: I have not spent too much time reading through both code bases, so this is not very detailed and I might be wrong in some aspects). These are the main differences I can see after a brief study:

  1. ormdantic uses a wrapper/decorator to make pydantic BaseModels behave like database tables as well, whereas sqlmodel inherits from pydantic BaseModel and uses a modified SQLAlchemy base model as its metaclass to achieve the same thing.

  2. In sqlmodel, the database connection is not built into the main class (SQLModel), but handled by separate equivalents of SQLAlchemy classes and functions (Session and create_engine).

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by yezz123
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@iron3oxide
Comment options

@yezz123
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
3 participants
Converted from issue

This discussion was converted from issue #19 on August 27, 2022 18:32.