Skip to content

Commit

Permalink
make api return object not array
Browse files Browse the repository at this point in the history
  • Loading branch information
sgmdlt committed Nov 29, 2023
1 parent 4ff3a96 commit b27784a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import traceback
import os
import psycopg
from psycopg.rows import dict_row

from dotenv import load_dotenv

Expand Down Expand Up @@ -37,7 +38,7 @@ def get_visits():
FROM visits
WHERE visits.datetime BETWEEN (%s) AND (%s);'''
conn = get_db()
with conn.cursor() as c:
with conn.cursor(row_factory=dict_row) as c:
c.execute(query, [begin_date, end_date])
res = c.fetchall()
return res
Expand All @@ -57,7 +58,7 @@ def get_registrations():
FROM registrations
WHERE registrations.datetime BETWEEN (%s) AND (%s);'''
conn = get_db()
with conn.cursor() as c:
with conn.cursor(row_factory=dict_row) as c:
c.execute(query, [begin_date, end_date])
res = c.fetchall()
return res

0 comments on commit b27784a

Please sign in to comment.