a
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import sqlite3
|
||||
import json
|
||||
|
||||
conn = sqlite3.connect('cms.db')
|
||||
c = conn.cursor()
|
||||
|
||||
# 把 news 模块的 content 从 {"count": 4} 改为 {"posts": [null, null, null, null]}
|
||||
c.execute("UPDATE home_modules SET content = ? WHERE type = 'news'",
|
||||
(json.dumps({"posts": [None, None, None, None]}),))
|
||||
print(f'已更新 {c.rowcount} 条 news 模块')
|
||||
conn.commit()
|
||||
|
||||
# 验证
|
||||
c.execute("SELECT content FROM home_modules WHERE type='news'")
|
||||
print('新 content:', c.fetchone()[0])
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user