Spaces:
Sleeping
Sleeping
from fastapi import FastAPI | |
import psycopg2 | |
import json | |
from psycopg2 import sql | |
import pandas as pd | |
app = FastAPI() | |
async def root(): | |
return {"greeting":"Hello world"} | |
db_params = { | |
'host': 'dpg-cnhir5fsc6pc73dvj380-a.oregon-postgres.render.com', | |
'database': 'OpenAI', | |
'user': 'anu', | |
'password': '5omRLogf9Kdas3zoBFPCT9yrCGU4IbEX', | |
} | |
def parse_csv(df): | |
res = df.to_json(orient="records") | |
parsed = json.loads(res) | |
return parsed | |
def ProfileMatchResults(): | |
dbQuery = "select * from profilematch" | |
conn = psycopg2.connect(**db_params) | |
df = pd.read_sql_query(dbQuery, conn) | |
return parse_csv(df) |