osaet/content/posts/blog-transfer-complete.md
yarnom f0b50d13ea feat: add admin publishing workflow and yar theme
Add Go/Postgres admin APIs, Angular admin UI, manual build flow, asset uploads, markdown import/export, configurable slug generation, and the Yar reading theme. Exclude local docs and generated development artifacts from version control.
2026-06-01 15:48:04 +08:00

1.1 KiB

id slug title summary status tags cover version slug_source slug_locked published_at created_at updated_at
d45ebe08-3f81-474f-a284-93170d866f5a blog-transfer-complete 博文转移完毕 published
1 manual true 2023-02-24T00:56:03+08:00 2023-02-24T00:56:03+08:00 2026-01-07T18:11:03+08:00

由于之前的博客存储在了 sqlite3 数据库里,显然是没办法直接导入 Hexo 所识别的格式的,所以用 python 写了 一个小脚本,方便博文的转移。

import sqlite3
from datetime import datetime
conn = sqlite3.connect("Hsunr.db")
cursor = conn.cursor()

cursor.execute('select * from post')
values = cursor.fetchall()
for item in values:
    file_name = "{}-{}.md".format(item[5],item[1].replace(' ','-'))
    dt_obj = datetime.strptime(item[0], '%Y%m%d%H%M%S')
    content = "---\\n" \\
              "title: {}\\n" \\
              "date: {}\\n" \\
              "tags:\\n" \\
              "categories: {}\\n" \\
              "---\\n"\\
              "{}".format(item[1],dt_obj,item[3],item[2])
    f = open(file_name,'w');
    f.write(content)