aio-libs / aiohttp-devtools

dev tools for aiohttp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sqlite support

flip111 opened this issue · comments

hello, i'm using the latest version of python, aiohttp and aiohttp-devtools (as of now). I would like to work with sqlite .. what can i do to the code to make that happen?

aiohttp-devtools is not a database driver :)
On other hand sqlite has no asynchronous API. The best what you can do is wrapping every DB call into run_in_executor. aioodbc is built using the same approach.
Technically you can connect to sqlite database using aioodbc driver but it looks like huge over-engineering.

Short answer for now is probably "use another database" :-(.

Closing this as it's not relevant to aiohttp-devtools.

aiohttp-devtools seems to be opinionated on postgres. I'm only asking which files do i need to modify to "use another database".

As for the technical discussion which database is suitable .. thanks for the information on sqlite and asynchronous API. I did some reading and i would like to try this library https://github.com/jreese/aiosqlite or this one https://github.com/RazerM/sqlalchemy_aio

aiosqlite is maybe the library you are looking for but I personally never used the project.

That's fine .. i can figure out some way to work with the database. But what should i keep from the default aiohttp-devtools template and what should i modify? You mentioned aioodbc as another option .. but this one is also not in the interactive choice when i run adev start. Perhaps it's better to start with the none database?

Unlike "batteries included" solutions like django, aiohttp doesn't make any constrains on what database you might like to use. There are therefore a large number of possible database backends, it's obviously impossible for aiohttp-devtools to provide a template for every single one.

To use another database backend, you'll likely want to add on_startup and on_cleanup methods to create an close your database connections. This is not specific to aiohttp-devtools, it's stardard aiohttp and I therefore recommend you read the server section of docs.aiohttp.org.