使用python将输入值插入sqlite3

时间:2013-03-27 03:24:19

标签: python sqlite

程序运行正常,但不会在数据库中插入任何内容。我不明白!

import sqlite3 as db

conn = db.connect('C:\\SQLite\\test.db')
cursor = conn.cursor()

answer = "ok"

while answer != "":

    title = raw_input("Enter film: ")
    year = raw_input("Enter year: ")
    director = raw_input("Enter director: ")

    cursor.execute("insert into films (title, year, director) values (?, ?, ?)", (title, year, director))

    answer = raw_input("Continue?  ")

conn.close()

0 个答案:

没有答案