mirror of
https://gitlab.com/JKANetwork/powerfulcomputermanager.git
synced 2026-02-21 04:23:44 +01:00
Changes to doc and api/app for be able to record more things
This commit is contained in:
19
sql.py
19
sql.py
@@ -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')
|
||||
Reference in New Issue
Block a user