From 29774d6574717b60cdcfea87ca71329dc19dd66c Mon Sep 17 00:00:00 2001 From: Corder Guy Date: Tue, 17 Apr 2018 14:41:13 -0500 Subject: [PATCH] Add row_factory --- mocha_server.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mocha_server.py b/mocha_server.py index e4bbcd1..727ee61 100755 --- a/mocha_server.py +++ b/mocha_server.py @@ -20,6 +20,7 @@ def get_users(username_list): This can also easily be done by user_id. """ conn = sqlite3.connect(DATABASE) + conn.row_factory = sqlite3.Row cursor = conn.cursor() output = [] 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? """ conn = sqlite3.connect(DATABASE) + conn.row_factory = sqlite3.Row cursor = conn.cursor() if desc == True: 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.row_factory = sqlite3.Row cursor = conn.cursor() cursor.execute("insert into users values (?,?)", (user_id, username)) conn.commit() @@ -87,6 +90,7 @@ def fetch_user(user_id): Also can return a list of all users if user_id == "*" """ conn = sqlite3.connect(DATABASE) + conn.row_factory = sqlite3.Row cursor = conn.cursor() if user_id != '*': # must use (?), (item,) format cursor.execute("SELECT * FROM users WHERE user_id=(?)", (user_id,))