From 4840b2db5c4d35849be0868f6ec1dde87b3da787 Mon Sep 17 00:00:00 2001 From: Mahendra Date: Sat, 7 Apr 2018 19:20:29 +0530 Subject: [PATCH] add docstring for sqlQuery and sqlBulkExecute methrod in helper_sql and removed query method of sqlBulkExecute class --- src/helper_sql.py | 20 +++++++------------- src/helper_startup.py | 8 ++++---- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/helper_sql.py b/src/helper_sql.py index 31bfe553..18e05e03 100644 --- a/src/helper_sql.py +++ b/src/helper_sql.py @@ -3,14 +3,15 @@ import threading import Queue -sqlSubmitQueue = Queue.Queue() # SQLITE3 is so thread-unsafe that they won't -# even let you call it from different threads using your own locks. SQL -# objects #can only be called from one thread. +sqlSubmitQueue = Queue.Queue() +# SQLITE3 is so thread-unsafe that they won't even let you call it from different threads using your own locks. +# SQL objects #can only be called from one thread. sqlReturnQueue = Queue.Queue() sqlLock = threading.Lock() def sqlQuery(sqlStatement, *args): + """SQLLITE execute statement and return query.""" sqlLock.acquire() sqlSubmitQueue.put(sqlStatement) @@ -76,6 +77,8 @@ def sqlStoredProcedure(procName): class SqlBulkExecute: + """This is used when you have to execute the same statement in a cycle.""" + def __enter__(self): sqlLock.acquire() return self @@ -86,19 +89,10 @@ class SqlBulkExecute: @staticmethod def execute(sqlStatement, *args): + """Used for statements that do not return results.""" sqlSubmitQueue.put(sqlStatement) if args == (): sqlSubmitQueue.put('') else: sqlSubmitQueue.put(args) sqlReturnQueue.get() - - @staticmethod - def query(sqlStatement, *args): - sqlSubmitQueue.put(sqlStatement) - - if args == (): - sqlSubmitQueue.put('') - else: - sqlSubmitQueue.put(args) - return sqlReturnQueue.get() diff --git a/src/helper_startup.py b/src/helper_startup.py index 13b4f0d2..aaab59d9 100644 --- a/src/helper_startup.py +++ b/src/helper_startup.py @@ -13,9 +13,9 @@ import paths import state import helper_random -storeConfigFilesInSameDirectoryAsProgramByDefault = False # The user may -# de-select Portable Mode in the settings if they want the config files to -# stay in the application data folder. +StoreConfigFilesInSameDirectoryAsProgramByDefault = False +# The user may de-select Portable Mode in the settings if they want the config +# files to stay in the application data folder. def _loadTrustedPeer(): @@ -130,7 +130,7 @@ def loadConfig(): ensureNamecoinOptions() - if storeConfigFilesInSameDirectoryAsProgramByDefault: + if StoreConfigFilesInSameDirectoryAsProgramByDefault: # Just use the same directory as the program and forget about # the appdata folder state.appdata = ''