Commit 5cfac18c authored by Julian Rother's avatar Julian Rother
Browse files

Change db code for compatability with mysql

parent c0340cc2
......@@ -41,7 +41,11 @@ def query(operation, *params):
request.db.execute(operation, params)
else:
return []
return request.db.fetchall()
try:
rows = request.db.fetchall()
except:
rows = []
return rows
@app.teardown_request
def commit_db(*args):
......
......@@ -105,8 +105,7 @@ CREATE TABLE IF NOT EXISTS `log` (
`time` datetime NOT NULL,
`object` varchar(10),
`obj_id` INTEGER,
`path` varchar(255) NOT NULL,
PRIMARY KEY (ip, id, time, path)
`path` varchar(255) NOT NULL
);
CREATE TABLE IF NOT EXISTS `streams` (
`handle` varchar(32) NOT NULL PRIMARY KEY,
......
......@@ -161,7 +161,7 @@ def edit():
'site_texts': ('site_texts', 'key', ['value']),
'videos': ('videos_data', 'id', ['visible'])
}
query('BEGIN TRANSACTION')
query('BEGIN')
if request.is_json:
changes = request.get_json().items()
else:
......@@ -172,7 +172,7 @@ def edit():
assert column in tabs[table][2]
query('UPDATE %s SET %s = ? WHERE %s = ?'%(tabs[table][0], column,
tabs[table][1]), val, id)
query('COMMIT TRANSACTION')
query('COMMIT')
return "OK", 200
@app.route('/auth')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment