dspace_statistics_api/app.py: Use parameterized SQL queries

This is a better way to run SQL queries because psycopg2 takes care
of the quoting for us.
This commit is contained in:
Alan Orth 2020-03-02 11:16:05 +02:00
parent 60e6ea57b1
commit 9e7dd28156
1 changed files with 2 additions and 3 deletions

View File

@ -29,9 +29,8 @@ class AllItemsResource:
# get statistics and use limit and offset to page through results
cursor.execute(
"SELECT id, views, downloads FROM items LIMIT {} OFFSET {}".format(
limit, offset
)
"SELECT id, views, downloads FROM items LIMIT %s OFFSET %s",
[limit, offset],
)
# create a list to hold dicts of item stats