Rewrite export script in Python; use build dir

This commit is contained in:
Samuel Sloniker 2022-11-25 09:24:55 -08:00
parent e5e046b70d
commit aa8fa31195
Signed by: kj7rrv
GPG Key ID: 1BB4029E66285A62
3 changed files with 21 additions and 8 deletions

1
.gitignore vendored
View File

@ -141,3 +141,4 @@ cython_debug/
*.db
*.db-journal
*.gptc
build/

20
export.py Normal file
View File

@ -0,0 +1,20 @@
import os
import shutil
import sqlite3
try:
shutil.rmtree("build")
except FileNotFoundError:
pass
os.mkdir("build")
shutil.copy("articles.db", "build/articles.db")
shutil.copy("sources.toml", "build/sources.toml")
shutil.copy("model.gptc", "build/model.gptc")
con = sqlite3.Connection("build/articles.db")
con.execute("UPDATE articles SET text = '***';")
con.commit()
con.execute("VACUUM;")
con.commit()
con.close()

View File

@ -1,8 +0,0 @@
#!/bin/sh
cp articles.db old_articles.db
sqlite3 articles.db 'UPDATE articles SET text = "***";'
sqlite3 articles.db 'VACUUM;'
echo -n "Press enter when done..."
read
rm articles.db
mv old_articles.db articles.db