Skip to content
Snippets Groups Projects
request_db.py 424 B
from typing import Dict, List
from labelstower import db

def send_query_to_db(query: str) -> List[Dict[int, str]] :
    '''
    Return the result of the query send to the database
    :param query: str
    :return: List[Dict[int, str]]
    '''
    result = []
    stmt = db.text(query)
    response = db.session.execute(stmt)
    for row in response:
         result.append({"id": row[0], "name": row[1]})
    return result