import sqlite3, json conn = sqlite3.connect('cms.db') c = conn.cursor() # 模拟前端保存的 content new_content = { "posts": [ { "id": 3, "title": "这5项指标反映糖尿病病情,却被很多糖友忽略了!", "summary": "summary text", "cover_image": "/storage/admin/images/202604/94c0d16c2996bb3ad55b6d9f09a7d7e8.png", "slug": "这5项指标反映糖尿病病情却被很多糖友忽略了", "category_name": "科普文章", "created_at": "2026-04-20" }, None, None, None ] } c.execute("UPDATE home_modules SET content = ? WHERE type = 'news'", (json.dumps(new_content, ensure_ascii=False),)) conn.commit() print(f'updated {c.rowcount} rows') c.execute("SELECT content FROM home_modules WHERE type='news'") print('saved:', c.fetchone()[0]) conn.close()