defa131 Remove blocking call to sqlite by using aiosqlite module.

Authored and Committed by cverna 4 years ago
    Remove blocking call to sqlite by using aiosqlite module.
    
    This commit removes the dependency to sqlalchemy to manage the
    sqlite connection and queries. The reason behind is that sqlalchemy
    is blocking the event loop in an asyncio context which made each
    request needed to have access to the sqlite databases blocking.
    
    The commit replaces sqlalchemy by aiosqlite a async sqlite wrapper
    around the sqlite3 module from the standard library.
    In order to make it easier to understand the code base, all the
    queries used and the classes used to store the queries results
    were moved to the mdapi/db.py module.
    The views are now stored in the mdapi.views.py and added to the
    application router in mdapi/server.py.
    The logic which forms the response to the requests based on the
    data gathered in the databases is present in mdapi/__init__.py.
    It might make sense to move this to the db.py module in a later
    commit.
    
    Before this commit mdapi answered an average of 28.5 requests
    per seconds for 100 concurent requests.
    After this commit mdapi answers an average of 97 requests
    per seconds for 100 concurent requests.
    
    Signed-off-by: Clement Verna <cverna@tutanota.com>
    
        
file modified
+1 -0
file modified
+6 -4
file modified
+31 -32
file modified
+2 -4
file modified
+97 -329
file removed
-58
file added
+196
file removed
-58
file modified
+13 -13
file removed
-276
file removed
-151
file modified
+43 -8
file added
+145
file modified
+3 -2
file modified
+6 -4
file modified
+4 -5