I have a sqlite.db file which has 5 columns and 10million rows. I have created a api using fastapi, now in one of the api methods I want to connect to that sqlite.db file and fetch content based on certain conditions (based on the columns present). I mostly will be using SELECT and WHERE.
How can I do it by also taking advantage of async requests. I have came across Tortoise ORM but I am not sure how to properly use it to fetch results.
from fastapi import FastAPI, UploadFile, File, Form
from fastapi.middleware.cors import CORSMiddleware
DATABASE_URL = "sqlite:///test.db"
@app.post("/test")
async def fetch_data(id: int):
query = "SELECT * FROM tablename WHERE ID={}".format(str(id))
# how can I fetch such query faster from 10 million records while taking advantage of async func
return results