helper_sql #467
|
@ -727,16 +727,15 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
# This is not a particularly commonly used API function. Before we
|
||||
# use it we'll need to fill out a field in our inventory database
|
||||
# which is blank by default (first20bytesofencryptedmessage).
|
||||
parameters = ''
|
||||
queryreturn = sqlQuery(
|
||||
'''SELECT hash, payload FROM inventory WHERE first20bytesofencryptedmessage = '' and objecttype = 'msg' ; ''')
|
||||
|
||||
for row in queryreturn:
|
||||
hash, payload = row
|
||||
readPosition = 16 # Nonce length + time length
|
||||
readPosition += decodeVarint(payload[readPosition:readPosition+10])[1] # Stream Number length
|
||||
t = (payload[readPosition:readPosition+20],hash)
|
||||
sqlExecute('''UPDATE inventory SET first20bytesofencryptedmessage=? WHERE hash=?; ''', t)
|
||||
with SqlBulkExecute() as sql:
|
||||
for row in queryreturn:
|
||||
hash, payload = row
|
||||
readPosition = 16 # Nonce length + time length
|
||||
readPosition += decodeVarint(payload[readPosition:readPosition+10])[1] # Stream Number length
|
||||
t = (payload[readPosition:readPosition+20],hash)
|
||||
sql.execute('''UPDATE inventory SET first20bytesofencryptedmessage=? WHERE hash=?; ''', t)
|
||||
|
||||
queryreturn = sqlQuery('''SELECT payload FROM inventory WHERE first20bytesofencryptedmessage = ?''',
|
||||
requestedHash)
|
||||
|
|
|
@ -558,7 +558,7 @@ class MyForm(QtGui.QMainWindow):
|
|||
else:
|
||||
where = "toaddress || fromaddress || subject || message"
|
||||
|
||||
sql = '''
|
||||
sqlStatement = '''
|
||||
SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime
|
||||
FROM sent WHERE folder="sent" AND %s LIKE ?
|
||||
ORDER BY lastactiontime
|
||||
|
@ -567,7 +567,7 @@ class MyForm(QtGui.QMainWindow):
|
|||
while self.ui.tableWidgetSent.rowCount() > 0:
|
||||
self.ui.tableWidgetSent.removeRow(0)
|
||||
|
||||
queryreturn = sqlQuery(sql, what)
|
||||
queryreturn = sqlQuery(sqlStatement, what)
|
||||
for row in queryreturn:
|
||||
toAddress, fromAddress, subject, message, status, ackdata, lastactiontime = row
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
|
@ -678,7 +678,7 @@ class MyForm(QtGui.QMainWindow):
|
|||
else:
|
||||
where = "toaddress || fromaddress || subject || message"
|
||||
|
||||
sql = '''
|
||||
sqlStatement = '''
|
||||
SELECT msgid, toaddress, fromaddress, subject, received, message, read
|
||||
FROM inbox WHERE folder="inbox" AND %s LIKE ?
|
||||
ORDER BY received
|
||||
|
@ -689,7 +689,7 @@ class MyForm(QtGui.QMainWindow):
|
|||
|
||||
font = QFont()
|
||||
font.setBold(True)
|
||||
queryreturn = sqlQuery(sql, what)
|
||||
queryreturn = sqlQuery(sqlStatement, what)
|
||||
for row in queryreturn:
|
||||
msgid, toAddress, fromAddress, subject, received, message, read = row
|
||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
|
|
|
@ -7,6 +7,7 @@ sqlLock = threading.Lock()
|
|||
|
||||
def sqlQuery(sqlStatement, *args):
|
||||
sqlLock.acquire()
|
||||
print 'sqlQuery args are:', args
|
||||
sqlSubmitQueue.put(sqlStatement)
|
||||
|
||||
if args == ():
|
||||
|
@ -21,6 +22,7 @@ def sqlQuery(sqlStatement, *args):
|
|||
|
||||
def sqlExecute(sqlStatement, *args):
|
||||
sqlLock.acquire()
|
||||
print 'sqlExecute args are:', args
|
||||
sqlSubmitQueue.put(sqlStatement)
|
||||
|
||||
if args == ():
|
||||
|
|
Reference in New Issue
Block a user