Using sync db drivers with sanic



So I am pretty new to web dev and sanic or async python in general, so I couldn’t think of a way to test this.
I built a wrapper around peewee to use it as an ORM with one of my projects. Could not use the peewee-async package since it does not support sqlite and my project needs sqlite. The wrapper works and all, but I read somewhere that using sync code with async code is a bad idea because sync code may block the entire event loop, when it executes.
As mentioned earlier I could not think of anything on how to test if the sync db driver is actually blocking up the event loop when run. So, is this theoretically correct? Or how could I test if the event loop is being blocked by the db driver?


It is not a bad idea, if it is the only solution you have. Nothing will go wrong by using it, and in fact a lot of times you may find that you need a sync package because they tend to be more robust and more well maintained.

The downside is that you will be blocking on those dB network requests. No way around it. But that may not be bad, depending on your use case. Just not as good as it could be.

I have not tried it myself yet, but @tomchristie just put out a new async dB package that I am pretty sure has sqlite support: Introducing the `databases` package