Untitled
unknown
plain_text
2 years ago
1.3 kB
6
Indexable
@router.post("/query") async def executeSingleQuery(request:RequestModel=Body(...,examples=get_request_example("single")), headers: Headers = Depends()): # noqa: E501 sql =request.sql[0] data_file = request.data_file try: if request.method != 'POST': raise HTTPException(status_code=405, detail='Method not allowed.') except Exception: raise HTTPException(status_code=400, detail="Invalid API method") if len(sql) > 1: raise HTTPException(status_code=400, detail="We don't want to execute a batch operation query") # noqa: E501 if (not headers.x_request_uid): raise HTTPException( status_code=400, detail="{x_request_uid} is missing and required in headers") if (not data_file): raise HTTPException( status_code=400, detail="The {file_data} is missing") request.sql: constr(regex=r'^(SELECT|select).*') con = duckDB_funcs.getConnection(threading.get_ident()) duckDB_funcs.verifyExistence(con=con,sql=sql,data_file = data_file) json_rows = duckDB_funcs.executeQuery(con=con, sql=sql) datamodelItem = DataItemModel(sql=sql,query_id="",execution_id="",data=json_rows) print(datamodelItem) # Create the response payload as an output response = ResponseDataModel(list[datamodelItem]) return response
Editor is loading...