我假设您需要python代码。
在内存中使用简单的
SQLite
How to work with sqlite3 and Python
考虑到你的例子,我们有一个数据列表。
import sqlite3
connection = sqlite3.connect("company.db")
cursor = connection.cursor()
staff_data = [ ("William", "Shakespeare", "m", "1961-10-25"),
("Frank", "Schiller", "m", "1955-08-17"),
("Jane", "Wall", "f", "1989-03-14") ]
for p in staff_data:
format_str = """INSERT INTO employee (staff_number, fname, lname, gender, birth_date)
VALUES (NULL, "{first}", "{last}", "{gender}", "{birthdate}");"""
sql_command = format_str.format(first=p[0], last=p[1], gender=p[2], birthdate = p[3])
cursor.execute(sql_command)
查看更多
here
.
.