首页 > 代码库 > 【Python】插入sqlite数据库

【Python】插入sqlite数据库

import sqlite3
from datetime import datetime

conn = sqlite3.connect(‘data.db‘)
print("Opened database successfully")

for i in range(100):
    time = datetime.now()
    conn.execute("INSERT INTO test(time,url,imgPath) VALUES (?,?,?)", (time, "www.test.com", "c:/data/" + str(i)))

conn.commit()
conn.close()

  

【Python】插入sqlite数据库