Starlette: Database Integration Recommendation(s)?

Created on 21 Oct 2018  Â·  4Comments  Â·  Source: encode/starlette

Firstly, apologies for asking this question in your issues but I wasn't sure of where a better forum would be.

I realize it isn't the aim of this project to be an everything, Django style solution, but I have to imagine that most use cases for starlette would involve working with some-sort of database. As most popular database solutions are sync rather than async, does anyone have a suggestion for where to look for a good async solution? Additionally, are there any recommendations for how to go about integrating one with starlette? Might something like Flask-SQLAlchemy, although not async friendly, be adapted, so as to at least keep it thread safe?

Thanks for any input!

I really love everything about starlette so far, more so with the overall API than with the performance itself, though that is great too.

Most helpful comment

I really love everything about starlette so far, more so with the overall API

Thanks! I think we’ve got a chance to do something a bit special here, by demonstrating how we can ensure an ecosystem of cross-framework-compatible middleware and components for ASGI.

Part of the guiding design here is that we shouldn’t really need to choose between “micro” frameworks and monolithic frameworks, but that if we pay enough to the design then we can have small, nicely isolated components, that easily compose into fully featured frameworks

All 4 comments

Searching for “Sanic ORM” or “aiohttp orm” might be helpful here.

This looks promising: https://github.com/05bit/peewee-async/blob/master/README.md

Also have a look at both of aiopg / asyncpg, and if there are any tools on top of those.

Really what we’d like to do will be to ensure that we run sync views with a threadpool, and provide sync interfaces onto reading the request body etc... in those cases.

That’ll be really nice, because eventually we’ll be able to provide websockets, sse, background tasks, timer/clock/startup/shutdown events all to either sync or async codebases.

I really love everything about starlette so far, more so with the overall API

Thanks! I think we’ve got a chance to do something a bit special here, by demonstrating how we can ensure an ecosystem of cross-framework-compatible middleware and components for ASGI.

Part of the guiding design here is that we shouldn’t really need to choose between “micro” frameworks and monolithic frameworks, but that if we pay enough to the design then we can have small, nicely isolated components, that easily compose into fully featured frameworks

Searching for “Sanic ORM” or “aiohttp orm” might be helpful here.

This looks promising: https://github.com/05bit/peewee-async/blob/master/README.md

Also have a look at both of aiopg / asyncpg, and if there are any tools on top of those.

_Really_ what we’d like to do will be to ensure that we run sync views with a threadpool, and provide sync interfaces onto reading the request body etc... in those cases.

That’ll be really nice, because eventually we’ll be able to provide websockets, sse, background tasks, timer/clock/startup/shutdown events all to _either_ sync or async codebases.

Thanks Tom, I will definitely take a look at those things and am looking at MotorEngine and GINO as well

We’ll want to add some docs here at some point.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomchristie picture tomchristie  Â·  3Comments

rlewkowicz picture rlewkowicz  Â·  3Comments

rugleb picture rugleb  Â·  4Comments

berislavlopac picture berislavlopac  Â·  5Comments

gnat picture gnat  Â·  6Comments