From 818401e464ac2bf974d30957d6f91d500bb7d3bf Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 4 Mar 2020 10:03:57 +1000 Subject: [PATCH] remove remaining db kwargs --- pylib/anki/find.py | 4 ++-- pylib/anki/models.py | 18 ++++-------------- pylib/anki/schedv2.py | 21 +++++---------------- 3 files changed, 11 insertions(+), 32 deletions(-) diff --git a/pylib/anki/find.py b/pylib/anki/find.py index 2067c3df6..a2c2b19c6 100644 --- a/pylib/anki/find.py +++ b/pylib/anki/find.py @@ -555,11 +555,11 @@ def findReplace( flds = joinFields(sflds) if flds != origFlds: nids.append(nid) - d.append(dict(nid=nid, flds=flds, u=col.usn(), m=intTime())) + d.append((flds, intTime(), col.usn(), nid)) if not d: return 0 # replace - col.db.executemany("update notes set flds=:flds,mod=:m,usn=:u where id=:nid", d) + col.db.executemany("update notes set flds=?,mod=?,usn=? where id=?", d) col.updateFieldCache(nids) col.genCards(nids) return len(d) diff --git a/pylib/anki/models.py b/pylib/anki/models.py index 21f27b649..461fd08a6 100644 --- a/pylib/anki/models.py +++ b/pylib/anki/models.py @@ -504,17 +504,9 @@ select id from notes where mid = ?)""" for c in range(nfields): flds.append(newflds.get(c, "")) flds = joinFields(flds) - d.append( - dict( - nid=nid, - flds=flds, - mid=newModel["id"], - m=intTime(), - u=self.col.usn(), - ) - ) + d.append((flds, newModel["id"], intTime(), self.col.usn(), nid,)) self.col.db.executemany( - "update notes set flds=:flds,mid=:mid,mod=:m,usn=:u where id = :nid", d + "update notes set flds=?,mid=?,mod=?,usn=? where id = ?", d ) self.col.updateFieldCache(nids) @@ -543,12 +535,10 @@ select id from notes where mid = ?)""" # mapping from a regular note, so the map should be valid new = map[ord] if new is not None: - d.append(dict(cid=cid, new=new, u=self.col.usn(), m=intTime())) + d.append((new, self.col.usn(), intTime(), cid)) else: deleted.append(cid) - self.col.db.executemany( - "update cards set ord=:new,usn=:u,mod=:m where id=:cid", d - ) + self.col.db.executemany("update cards set ord=?,usn=?,mod=? where id=?", d) self.col.remCards(deleted) # Schema hash diff --git a/pylib/anki/schedv2.py b/pylib/anki/schedv2.py index a9a7eadd2..67aa6c4db 100644 --- a/pylib/anki/schedv2.py +++ b/pylib/anki/schedv2.py @@ -1775,21 +1775,12 @@ and (queue={QUEUE_TYPE_NEW} or (queue={QUEUE_TYPE_REV} and due<=?))""", mod = intTime() for id in ids: r = random.randint(imin, imax) - d.append( - dict( - id=id, - due=r + t, - ivl=max(1, r), - mod=mod, - usn=self.col.usn(), - fact=STARTING_FACTOR, - ) - ) + d.append((max(1, r), r + t, self.col.usn(), mod, STARTING_FACTOR, id,)) self.remFromDyn(ids) self.col.db.executemany( f""" -update cards set type={CARD_TYPE_REV},queue={QUEUE_TYPE_REV},ivl=:ivl,due=:due,odue=0, -usn=:usn,mod=:mod,factor=:fact where id=:id""", +update cards set type={CARD_TYPE_REV},queue={QUEUE_TYPE_REV},ivl=?,due=?,odue=0, +usn=?,mod=?,factor=? where id=?""", d, ) self.col.log(ids) @@ -1866,10 +1857,8 @@ and due >= ? and queue = {QUEUE_TYPE_NEW}""" for id, nid in self.col.db.execute( f"select id, nid from cards where type = {CARD_TYPE_NEW} and id in " + scids ): - d.append(dict(now=now, due=due[nid], usn=self.col.usn(), cid=id)) - self.col.db.executemany( - "update cards set due=:due,mod=:now,usn=:usn where id = :cid", d - ) + d.append((due[nid], now, self.col.usn(), id)) + self.col.db.executemany("update cards set due=?,mod=?,usn=? where id = ?", d) def randomizeCards(self, did: int) -> None: cids = self.col.db.list("select id from cards where did = ?", did)