Move duplicated sql code into helper
This commit is contained in:
parent
61c9251183
commit
edf9101eae
33
src/helper_sql.py
Normal file
33
src/helper_sql.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import shared
|
||||
|
||||
def sqlQuery(sqlStatement, *args):
|
||||
shared.sqlLock.acquire()
|
||||
shared.sqlSubmitQueue.put(sqlStatement)
|
||||
|
||||
if args == ():
|
||||
shared.sqlSubmitQueue.put('')
|
||||
else:
|
||||
shared.sqlSubmitQueue.put(args)
|
||||
|
||||
queryreturn = shared.sqlReturnQueue.get()
|
||||
shared.sqlLock.release()
|
||||
|
||||
return queryreturn
|
||||
|
||||
def sqlExecute(sqlStatement, *args):
|
||||
shared.sqlLock.acquire()
|
||||
shared.sqlSubmitQueue.put(sqlStatement)
|
||||
|
||||
if args == ():
|
||||
shared.sqlSubmitQueue.put('')
|
||||
else:
|
||||
shared.sqlSubmitQueue.put(args)
|
||||
|
||||
shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
shared.sqlLock.release()
|
||||
|
||||
def sqlStoredProcedure(procName):
|
||||
shared.sqlLock.acquire()
|
||||
shared.sqlSubmitQueue.put(procName)
|
||||
shared.sqlLock.release()
|
Reference in New Issue
Block a user