该程序是使用Python把sqlite的article表中的content字段全部由markdown转换为html。 首先安装依赖:

pip install sqlite3
pipinstall markdown

以下是程序主体:

import sqlite3
import markdown
conn = sqlite3.connect('test.db')
cursor = conn.cursor()
for i in range(0,900):
	try:
		a = cursor.execute('select content from articles where id = %s'%i).fetchall()
		for a1 in a:
			cursor.execute("update articles set content = '%s' where id = '%s'"%(markdown.markdown(a1[0]),i))
			conn.commit()
	except:
		continue

经测试python2和python3都可以正常运行。