Improve PEP8 compliance
This commit is contained in:
parent
cd040dfd89
commit
2502d9c7f4
1 changed files with 15 additions and 7 deletions
|
@ -2,6 +2,7 @@
|
|||
'''
|
||||
Handle API requests to the database
|
||||
'''
|
||||
|
||||
import json
|
||||
import sqlite3
|
||||
from os import path
|
||||
|
@ -13,6 +14,7 @@ if not path.exists(DATABASE):
|
|||
# TODO: Add fetching of top N users by score
|
||||
# TODO: Add ability to store and retrieve avatars (as image files?)
|
||||
|
||||
|
||||
def fetch_users(user_ids):
|
||||
'''
|
||||
Gets a list of users searching by name.
|
||||
|
@ -39,9 +41,12 @@ def fetch_users(user_ids):
|
|||
def get_top_n(search_parameter, desc, num):
|
||||
'''
|
||||
In progress.
|
||||
Currently the query seems to work, but returning a dict does not preserve order.
|
||||
Currently the query seems to work, but returning a dict does not
|
||||
preserve order.
|
||||
|
||||
Store an orderd id list and put that in the json?
|
||||
|
||||
Alternatively, sort on the client-side.
|
||||
'''
|
||||
conn = sqlite3.connect(DATABASE)
|
||||
conn.row_factory = sqlite3.Row
|
||||
|
@ -54,7 +59,7 @@ def get_top_n(search_parameter, desc, num):
|
|||
(search_parameter, num))
|
||||
|
||||
output = cursor.fetchall()
|
||||
#print(output)
|
||||
# print(output)
|
||||
|
||||
output = json.dumps([dict(row) for row in output])
|
||||
conn.commit()
|
||||
|
@ -78,7 +83,10 @@ def update_row(_user_id, _updated_username):
|
|||
def insert_row(user_id, username):
|
||||
'''
|
||||
Inserts a row for a NEW user with given parameters
|
||||
This may work better with AUTOINCREMENT to avoid arbitrary ids and duplicates
|
||||
This may work better with AUTOINCREMENT to avoid arbitrary ids and
|
||||
duplicates.
|
||||
|
||||
Alternatively, use randomized unique IDs.
|
||||
'''
|
||||
|
||||
conn = sqlite3.connect(DATABASE)
|
||||
|
|
Reference in a new issue