use executemany instead of batched_operation
This commit is contained in:
parent
56c41b2fea
commit
9d89f9b834
1 changed files with 3 additions and 10 deletions
|
@ -105,13 +105,6 @@ def get_content_claim_from_outpoint(transaction: sqlite3.Connection,
|
||||||
return StoredStreamClaim(*claim_fields)
|
return StoredStreamClaim(*claim_fields)
|
||||||
|
|
||||||
|
|
||||||
def batched_operation(transaction, query, parameters, batch_size=900):
|
|
||||||
for start_index in range(0, len(parameters), batch_size):
|
|
||||||
current_batch = parameters[start_index:start_index+batch_size]
|
|
||||||
bind = "({})".format(','.join(['?'] * len(current_batch)))
|
|
||||||
transaction.execute(query.format(bind), current_batch)
|
|
||||||
|
|
||||||
|
|
||||||
def _batched_select(transaction, query, parameters, batch_size=900):
|
def _batched_select(transaction, query, parameters, batch_size=900):
|
||||||
for start_index in range(0, len(parameters), batch_size):
|
for start_index in range(0, len(parameters), batch_size):
|
||||||
current_batch = parameters[start_index:start_index+batch_size]
|
current_batch = parameters[start_index:start_index+batch_size]
|
||||||
|
@ -162,13 +155,13 @@ def get_all_lbry_files(transaction: sqlite3.Connection) -> typing.List[typing.Di
|
||||||
|
|
||||||
|
|
||||||
def delete_stream(transaction: sqlite3.Connection, descriptor: 'StreamDescriptor'):
|
def delete_stream(transaction: sqlite3.Connection, descriptor: 'StreamDescriptor'):
|
||||||
blob_hashes = [blob.blob_hash for blob in descriptor.blobs[:-1]]
|
blob_hashes = [(blob.blob_hash, ) for blob in descriptor.blobs[:-1]]
|
||||||
blob_hashes.append(descriptor.sd_hash)
|
blob_hashes.append((descriptor.sd_hash, ))
|
||||||
transaction.execute("delete from content_claim where stream_hash=? ", (descriptor.stream_hash,))
|
transaction.execute("delete from content_claim where stream_hash=? ", (descriptor.stream_hash,))
|
||||||
transaction.execute("delete from file where stream_hash=? ", (descriptor.stream_hash,))
|
transaction.execute("delete from file where stream_hash=? ", (descriptor.stream_hash,))
|
||||||
transaction.execute("delete from stream_blob where stream_hash=?", (descriptor.stream_hash,))
|
transaction.execute("delete from stream_blob where stream_hash=?", (descriptor.stream_hash,))
|
||||||
transaction.execute("delete from stream where stream_hash=? ", (descriptor.stream_hash,))
|
transaction.execute("delete from stream where stream_hash=? ", (descriptor.stream_hash,))
|
||||||
batched_operation(transaction, "delete from blob where blob_hash in {}", blob_hashes)
|
transaction.executemany("delete from blob where blob_hash=?", blob_hashes)
|
||||||
|
|
||||||
|
|
||||||
class SQLiteStorage(SQLiteMixin):
|
class SQLiteStorage(SQLiteMixin):
|
||||||
|
|
Loading…
Reference in a new issue