aboutsummaryrefslogtreecommitdiffstats
path: root/dbupdate.py
diff options
context:
space:
mode:
authorBlake DeMarcy <ofunknowndescent@gmail.com>2017-04-25 03:36:51 -0500
committerBlake DeMarcy <ofunknowndescent@gmail.com>2017-04-25 03:36:51 -0500
commit0f6846c3609c3b8caa34a296355e06d18261a1e1 (patch)
tree4fc46a36625b844f3c65ddd7b6062ea01b23efe0 /dbupdate.py
parent90b5573f842e1be81743194705fa94c41969da61 (diff)
downloadbbj-0f6846c3609c3b8caa34a296355e06d18261a1e1.tar.gz
add new parameter to threads: last_author
Diffstat (limited to 'dbupdate.py')
-rw-r--r--dbupdate.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/dbupdate.py b/dbupdate.py
new file mode 100644
index 0000000..717feb1
--- /dev/null
+++ b/dbupdate.py
@@ -0,0 +1,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