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 threading
|
||||||
import Queue
|
import Queue
|
||||||
|
|
||||||
sqlSubmitQueue = Queue.Queue() # SQLITE3 is so thread-unsafe that they won't
|
sqlSubmitQueue = Queue.Queue()
|
||||||
# even let you call it from different threads using your own locks. SQL
|
# SQLITE3 is so thread-unsafe that they won't even let you call it from different threads using your own locks.
|
||||||
# objects #can only be called from one thread.
|
# SQL objects #can only be called from one thread.
|
||||||
sqlReturnQueue = Queue.Queue()
|
sqlReturnQueue = Queue.Queue()
|
||||||
sqlLock = threading.Lock()
|
sqlLock = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
def sqlQuery(sqlStatement, *args):
|
def sqlQuery(sqlStatement, *args):
|
||||||
|
"""SQLLITE execute statement and return query."""
|
||||||
sqlLock.acquire()
|
sqlLock.acquire()
|
||||||
sqlSubmitQueue.put(sqlStatement)
|
sqlSubmitQueue.put(sqlStatement)
|
||||||
|
|
||||||
|
@ -76,6 +77,8 @@ def sqlStoredProcedure(procName):
|
||||||
|
|
||||||
|
|
||||||
class SqlBulkExecute:
|
class SqlBulkExecute:
|
||||||
|
"""This is used when you have to execute the same statement in a cycle."""
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
sqlLock.acquire()
|
sqlLock.acquire()
|
||||||
return self
|
return self
|
||||||
|
@ -86,19 +89,10 @@ class SqlBulkExecute:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def execute(sqlStatement, *args):
|
def execute(sqlStatement, *args):
|
||||||
|
"""Used for statements that do not return results."""
|
||||||
sqlSubmitQueue.put(sqlStatement)
|
sqlSubmitQueue.put(sqlStatement)
|
||||||
if args == ():
|
if args == ():
|
||||||
sqlSubmitQueue.put('')
|
sqlSubmitQueue.put('')
|
||||||
else:
|
else:
|
||||||
sqlSubmitQueue.put(args)
|
sqlSubmitQueue.put(args)
|
||||||
sqlReturnQueue.get()
|
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 state
|
||||||
import helper_random
|
import helper_random
|
||||||
|
|
||||||
storeConfigFilesInSameDirectoryAsProgramByDefault = False # The user may
|
StoreConfigFilesInSameDirectoryAsProgramByDefault = False
|
||||||
# de-select Portable Mode in the settings if they want the config files to
|
# The user may de-select Portable Mode in the settings if they want the config
|
||||||
# stay in the application data folder.
|
# files to stay in the application data folder.
|
||||||
|
|
||||||
|
|
||||||
def _loadTrustedPeer():
|
def _loadTrustedPeer():
|
||||||
|
@ -130,7 +130,7 @@ def loadConfig():
|
||||||
|
|
||||||
ensureNamecoinOptions()
|
ensureNamecoinOptions()
|
||||||
|
|
||||||
if storeConfigFilesInSameDirectoryAsProgramByDefault:
|
if StoreConfigFilesInSameDirectoryAsProgramByDefault:
|
||||||
# Just use the same directory as the program and forget about
|
# Just use the same directory as the program and forget about
|
||||||
# the appdata folder
|
# the appdata folder
|
||||||
state.appdata = ''
|
state.appdata = ''
|
||||||
|
|
Loading…
Reference in New Issue
Block a user