Changes to doc and api/app for be able to record more things

This commit is contained in:
2019-11-19 09:01:26 +01:00
parent 9de38014be
commit cbe562da96
9 changed files with 105 additions and 140 deletions

19
sql.py
View File

@@ -1,6 +1,5 @@
# Build 2
# Build 3
import sqlite3
import sysopt #File of options
from shutil import copyfile
from os import path
from datetime import datetime
@@ -27,24 +26,32 @@ def dict_factory(cursor, row):
def select(query):
conn = sqlite3.connect('BD/database.db')
conn.row_factory = dict_factory
if sysopt.debugsql==True:
if debugsql==True:
logit("SQL: "+query)
cur = conn.execute(query)
return cur.fetchall()
def insert(query):
conn = sqlite3.connect('BD/database.db')
if sysopt.debugsql==True:
if debugsql==True:
logit("SQL: "+query)
try:
c = conn.cursor()
c.execute(query)
conn.commit()
conn.close()
if sysopt.debugsql==True:
if debugsql==True:
logit("SQL Ok")
return {'RESULT': 'OK'}
except:
if sysopt.debugsql==True:
if debugsql==True:
logit("SQL Error")
return {'RESULT': 'SQLite3 Error'}
def retOption(option):
try:
return select("SELECT Value FROM OPTIONS WHERE Option='"+option+"'")[0]['Value']
except:
return None
debugsql = retOption('DebugSQL')