Add row_factory
This commit is contained in:
parent
cc17637c99
commit
29774d6574
1 changed files with 4 additions and 0 deletions
|
@ -20,6 +20,7 @@ def get_users(username_list):
|
||||||
This can also easily be done by user_id.
|
This can also easily be done by user_id.
|
||||||
"""
|
"""
|
||||||
conn = sqlite3.connect(DATABASE)
|
conn = sqlite3.connect(DATABASE)
|
||||||
|
conn.row_factory = sqlite3.Row
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
output = []
|
output = []
|
||||||
for usr in username_list:
|
for usr in username_list:
|
||||||
|
@ -44,6 +45,7 @@ def get_top_N(search_parameter, desc, N):
|
||||||
Store an orderd id list and put that in the json?
|
Store an orderd id list and put that in the json?
|
||||||
"""
|
"""
|
||||||
conn = sqlite3.connect(DATABASE)
|
conn = sqlite3.connect(DATABASE)
|
||||||
|
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))
|
||||||
|
@ -75,6 +77,7 @@ def insert_row(user_id, username):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
conn = sqlite3.connect(DATABASE)
|
conn = sqlite3.connect(DATABASE)
|
||||||
|
conn.row_factory = sqlite3.Row
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute("insert into users values (?,?)", (user_id, username))
|
cursor.execute("insert into users values (?,?)", (user_id, username))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
@ -87,6 +90,7 @@ def fetch_user(user_id):
|
||||||
Also can return a list of all users if user_id == "*"
|
Also can return a list of all users if user_id == "*"
|
||||||
"""
|
"""
|
||||||
conn = sqlite3.connect(DATABASE)
|
conn = sqlite3.connect(DATABASE)
|
||||||
|
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,))
|
||||||
|
|
Reference in a new issue