add docstring for sqlQuery and sqlBulkExecute methrod in helper_sql and removed query method of sqlBulkExecute class
This commit is contained in:
parent
a3dff6200e
commit
4840b2db5c
|
@ -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()
|
||||
|
|
|
@ -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 = ''
|
||||
|
|
Reference in New Issue
Block a user