aboutsummaryrefslogtreecommitdiffstats
path: root/dbupdate.py
blob: 717feb1c161f369509a1c2c52e72dbcdff5152a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
import sqlite3

with sqlite3.connect("data.sqlite") as _con:
    _con.execute('ALTER TABLE threads ADD COLUMN last_author text DEFAULT ""')
    _con.commit()
    for tid in _con.execute("SELECT thread_id FROM threads"):
        author = _con.execute("SELECT author FROM messages WHERE thread_id = ? ORDER BY post_id", tid).fetchall()[-1]
        _con.execute("UPDATE threads SET last_author = ? WHERE thread_id = ?", author + tid)
    _con.commit()
Un proyecto texto-plano.xyz