Skip to content

Instantly share code, notes, and snippets.

@qaqland
Created January 24, 2024 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qaqland/560dcd6ae032dd9141c859415470c59e to your computer and use it in GitHub Desktop.
Save qaqland/560dcd6ae032dd9141c859415470c59e to your computer and use it in GitHub Desktop.
Export data of purewriter time machine 导出纯纯写作时光机数据
# unpack file.pwb and get the db file
# edit $your-sqlite-db-file to yours path
# use pipe to export to txt
import sqlite3, datetime, json
conn = sqlite3.connect("your-sqlite-db-file")
conn.row_factory = sqlite3.Row
cur = conn.cursor()
query = "SELECT content, createdTime FROM UserMessage ORDER BY createdTime"
rows = cur.execute(query).fetchall()
msgs = [dict(row) for row in rows]
conn.close()
for msg in msgs:
timestamp = msg["createdTime"]
timestamp = datetime.datetime.fromtimestamp(timestamp / 1000.0)
timestamp = timestamp.strftime("%Y-%m-%d %H:%M:%S")
print(f"\n[{timestamp}]")
json_string = msg["content"].decode("utf-8")
json_data = json.loads(json_string)
print(json_data["text"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment