old changes (sorry)
This commit is contained in:
parent
9e2ff9936b
commit
b2a546aa77
4 changed files with 12 additions and 2 deletions
Binary file not shown.
BIN
mocha.db
BIN
mocha.db
Binary file not shown.
|
@ -19,6 +19,15 @@ cursor = conn.cursor()
|
||||||
# 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 update_steps(user_id, steps):
|
||||||
|
"""
|
||||||
|
Overwrites the old raw_steps value.
|
||||||
|
This can be changed to increment it if needed.
|
||||||
|
"""
|
||||||
|
cursor.execute("update users set raw_steps=? where user_id=?", (steps, user_id))
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
|
||||||
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.
|
||||||
|
@ -74,7 +83,6 @@ 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
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cursor.execute("insert into users values (?,?)", (user_id, username))
|
cursor.execute("insert into users values (?,?)", (user_id, username))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
#conn.close()
|
#conn.close()
|
||||||
|
|
4
test.py
4
test.py
|
@ -8,5 +8,7 @@ import mocha_server
|
||||||
|
|
||||||
username_list = ['andrew', 'Corder']
|
username_list = ['andrew', 'Corder']
|
||||||
|
|
||||||
print(mocha_server.get_users(username_list))
|
|
||||||
|
|
||||||
|
mocha_server.update_steps(4, 1234)
|
||||||
|
mocha_server.update_steps(2, 5678)
|
||||||
|
print(mocha_server.get_users(username_list))
|
||||||
|
|
Reference in a new issue