Reorganize files
This commit is contained in:
parent
f7a9b9b7b8
commit
958cda62b7
5 changed files with 7 additions and 7 deletions
|
@ -1,4 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
"""Handle API requests to the database
|
||||||
|
something
|
||||||
|
"""
|
||||||
import json
|
import json
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
|
@ -9,14 +12,14 @@ DATABASE = '/usr/local/www/mocha-server/mocha.db'
|
||||||
def fetch(user_id):
|
def fetch(user_id):
|
||||||
conn = sqlite3.connect(DATABASE)
|
conn = sqlite3.connect(DATABASE)
|
||||||
conn.row_factory = sqlite3.Row
|
conn.row_factory = sqlite3.Row
|
||||||
c = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
if user_id != '*':
|
if user_id != '*':
|
||||||
c.execute("SELECT * FROM users WHERE user_id=?", user_id)
|
cursor.execute("SELECT * FROM users WHERE user_id=?", user_id)
|
||||||
else:
|
else:
|
||||||
c.execute("SELECT * FROM users")
|
cursor.execute("SELECT * FROM users")
|
||||||
|
|
||||||
output = c.fetchall()
|
output = cursor.fetchall()
|
||||||
output = json.dumps([dict(row) for row in output])
|
output = json.dumps([dict(row) for row in output])
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
-r base.txt
|
|
|
@ -1 +0,0 @@
|
||||||
-r base.txt
|
|
|
@ -1 +0,0 @@
|
||||||
-r base.txt
|
|
Reference in a new issue