[HN Gopher] SQLModel - SQL Databases in FastAPI
___________________________________________________________________
SQLModel - SQL Databases in FastAPI
Author : dmart
Score : 63 points
Date : 2021-08-24 20:26 UTC (2 hours ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| tiangolo wrote:
| Hey all! Author here!
|
| Thanks for sharing!
|
| This is the biggest thing I've built since FastAPI and Typer...
|
| SQLModel is a library for interacting with SQL DBs, based on
| Python type hints.
|
| Each model is both a Pydantic and SQLAlchemy model, and it's all
| optimized for FastAPI.
|
| GitHub here: https://github.com/tiangolo/sqlmodel
|
| More info in this Twitter thread:
| https://twitter.com/tiangolo/status/1430252646968004612
|
| And the docs are here: https://sqlmodel.tiangolo.com/
| kbumsik wrote:
| Cool project!
|
| Just wanted to mention that you emphasize "optimized for
| FastAPI" but it looks like it does nothing to do with FastAPI.
|
| Do you have any reason to narrow down the scope to FastAPI when
| other frameworks like Flask are still more widely used?
|
| Specifically mentioning only one framework causes loosing
| interest of people who use other frameworks.
| scrollaway wrote:
| I'm curious and excited. Have you talked about the differences
| between this and TortoiseORM yet? The latter has the big
| advantage of having an api familiar to Django users.
|
| In short, what motivated you to write your own rather than
| "bless" one of the existing ones?
|
| I see the approach that this isn't exactly an orm, it's more of
| an api wrapper around it (SQLalchemy in that case), is that
| correct?
| jkrubin wrote:
| If tiangolo is involved it will be very polished by 0.1.0
| hangonhn wrote:
| Does it work outside of FastAPI or is it tied to it? We sort of
| shoved SQLAlchemy into Starlette (which FastAPI also uses) and it
| would be great if this library also works with Starlette. Thanks!
| tiangolo wrote:
| Yes of course! It is based on (and depends on) SQLAlchemy and
| Pydantic.
|
| And SQLModel, the same as those two dependencies, are
| independent of any framework, so you can combine them with
| anything you need.
| hangonhn wrote:
| Thanks! This could potentially save us a ton of work! Really
| appreciate all the amazing work you've done. FastAPI
| definitely being put to good use at my company.
| woile wrote:
| Super nice! Always delivering quality tools. This also seems to
| play good with starlette as well. And I see async and migrations
| are coming soon. Alembic is good but a bit cumbersome to use, I
| hope to see some improvements there as well
| gabereiser wrote:
| While I'm a fan of both pydantic and SQLAlchemy, I feel like
| support for this should be more clear in pydantic. We have the
| `.from_orm` method and we have sqlalchemy model metadata. This
| project wraps them nicely but I shouldn't have to have separate
| glue code for this. Until we have cleaner pydantic/sqlalchemy
| integration for FastAPI, the OP's project will do just nicely.
| Great job. I fully expect FastAPI with it's reliance on pydantic
| to help push better support for ORM models though. Anyway, enough
| ranting and back to coding.
| easton wrote:
| I was literally an hour ago trying to figure out how to get my
| complicated Pydantic models to convert correctly to the
| SQLAlchemy models I made. Thanks tiangolo!
| gigatexal wrote:
| That it uses SQLAlchemy bring the scenes is a deal breaker for
| me.
___________________________________________________________________
(page generated 2021-08-24 23:00 UTC)