From edf9101eae52ce0a3f87b8f233e3f8ba1dcbbee0 Mon Sep 17 00:00:00 2001 From: "Grant T. Olson" Date: Mon, 26 Aug 2013 20:00:30 -0400 Subject: [PATCH] Move duplicated sql code into helper --- src/helper_sql.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/helper_sql.py diff --git a/src/helper_sql.py b/src/helper_sql.py new file mode 100644 index 00000000..f32a31d4 --- /dev/null +++ b/src/helper_sql.py @@ -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()