Skip to content

Commit 7218d7d

Browse files
committed
Refactor librefm.py db updates
1 parent e6789fe commit 7218d7d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

plugins/librefm.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ def librefm(text, nick, db, notice):
123123
out += ending
124124

125125
if text and not dontsave:
126-
db.execute("insert or replace into librefm(nick, acc) values (:nick, :account)",
127-
{'nick': nick.lower(), 'account': user})
126+
res = db.execute(table.update().values(acc=user).where(table.c.nick == nick.lower()))
127+
if res.rowcount <= 0:
128+
db.execute(table.insert().values(nick=nick.lower(), acc=user))
129+
128130
db.commit()
129131
load_cache(db)
130132
return out

0 commit comments

Comments
 (0)