MCPcopy Create free account
hub / github.com/Bitmessage/PyBitmessage / sqlExecuteChunked

Function sqlExecuteChunked

src/helper_sql.py:25–52  ·  view source on GitHub ↗
(sqlStatement, idCount, *args)

Source from the content-addressed store, hash-verified

23
24
25def sqlExecuteChunked(sqlStatement, idCount, *args):
26 # SQLITE_MAX_VARIABLE_NUMBER,
27 # unfortunately getting/setting isn't exposed to python
28 sqlExecuteChunked.chunkSize = 999
29
30 if idCount == 0 or idCount > len(args):
31 return 0
32
33 totalRowCount = 0
34 with sqlLock:
35 for i in range(
36 len(args) - idCount, len(args),
37 sqlExecuteChunked.chunkSize - (len(args) - idCount)
38 ):
39 chunk_slice = args[
40 i:i+sqlExecuteChunked.chunkSize - (len(args) - idCount)
41 ]
42 sqlSubmitQueue.put(
43 sqlStatement.format(','.join('?' * len(chunk_slice)))
44 )
45 # first static args, and then iterative chunk
46 sqlSubmitQueue.put(
47 args[0:len(args)-idCount] + chunk_slice
48 )
49 retVal = sqlReturnQueue.get()
50 totalRowCount += retVal[1]
51 sqlSubmitQueue.put('commit')
52 return totalRowCount
53
54
55def sqlExecute(sqlStatement, *args):

Callers 4

on_action_MarkAllReadMethod · 0.90
on_action_InboxTrashMethod · 0.90

Calls 2

putMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected