Add vim modeline
This commit is contained in:
parent
29774d6574
commit
a38d1f4409
1 changed files with 13 additions and 8 deletions
|
@ -14,6 +14,7 @@ if not path.exists(DATABASE):
|
||||||
# TODO: Add fetching of top N users by score
|
# TODO: Add fetching of top N users by score
|
||||||
# TODO: Add ability to store and retrieve avatars (as image files?)
|
# TODO: Add ability to store and retrieve avatars (as image files?)
|
||||||
|
|
||||||
|
|
||||||
def get_users(username_list):
|
def get_users(username_list):
|
||||||
"""
|
"""
|
||||||
Gets a list of users searching by name.
|
Gets a list of users searching by name.
|
||||||
|
@ -24,7 +25,7 @@ def get_users(username_list):
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
output = []
|
output = []
|
||||||
for usr in username_list:
|
for usr in username_list:
|
||||||
cursor.execute("select * from users where username=(?)", (usr,))
|
cursor.execute("select * from users where username=(?)", (usr, ))
|
||||||
output += cursor.fetchall()
|
output += cursor.fetchall()
|
||||||
|
|
||||||
output = json.dumps([dict(row) for row in output])
|
output = json.dumps([dict(row) for row in output])
|
||||||
|
@ -48,9 +49,11 @@ def get_top_N(search_parameter, desc, N):
|
||||||
conn.row_factory = sqlite3.Row
|
conn.row_factory = sqlite3.Row
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
if desc == True:
|
if desc == True:
|
||||||
cursor.execute("select * from users order by ? desc limit ?", (search_parameter, N))
|
cursor.execute("select * from users order by ? desc limit ?",
|
||||||
|
(search_parameter, N))
|
||||||
else:
|
else:
|
||||||
cursor.execute("select * from users order by ? asc limit ?", (search_parameter, N))
|
cursor.execute("select * from users order by ? asc limit ?",
|
||||||
|
(search_parameter, N))
|
||||||
|
|
||||||
output = cursor.fetchall()
|
output = cursor.fetchall()
|
||||||
#print(output)
|
#print(output)
|
||||||
|
@ -72,9 +75,9 @@ def update_row(user_id, updated_username):
|
||||||
|
|
||||||
def insert_row(user_id, username):
|
def insert_row(user_id, username):
|
||||||
"""
|
"""
|
||||||
Inserts a row for a NEW user with given parameters
|
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
|
||||||
"""
|
"""
|
||||||
|
|
||||||
conn = sqlite3.connect(DATABASE)
|
conn = sqlite3.connect(DATABASE)
|
||||||
conn.row_factory = sqlite3.Row
|
conn.row_factory = sqlite3.Row
|
||||||
|
@ -92,8 +95,8 @@ def fetch_user(user_id):
|
||||||
conn = sqlite3.connect(DATABASE)
|
conn = sqlite3.connect(DATABASE)
|
||||||
conn.row_factory = sqlite3.Row
|
conn.row_factory = sqlite3.Row
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
if user_id != '*': # must use (?), (item,) format
|
if user_id != '*': # must use (?), (item,) format
|
||||||
cursor.execute("SELECT * FROM users WHERE user_id=(?)", (user_id,))
|
cursor.execute("SELECT * FROM users WHERE user_id=(?)", (user_id, ))
|
||||||
else:
|
else:
|
||||||
cursor.execute("SELECT * FROM users")
|
cursor.execute("SELECT * FROM users")
|
||||||
|
|
||||||
|
@ -156,3 +159,5 @@ def application(environ, start_response):
|
||||||
start_response(status, response_headers)
|
start_response(status, response_headers)
|
||||||
|
|
||||||
return [output]
|
return [output]
|
||||||
|
|
||||||
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4 expandtab
|
||||||
|
|
Reference in a new issue