SQLite无法使用Python覆盖默认值

时间:2016-11-19 14:59:19

标签: python sql sqlite sqlalchemy

我正在玩SQLite和python。我正在使用sqlalchemy并有一个像这样的表设置:

quizzes = Table("quizzes", metadata,
    Column("id", Integer, primary_key = True),
    Column("subject", String, default = "Math"),
    Column("description", String),
    Column("answer_a", String),
    Column("answer_b", String),
    Column("answer_c", String),
    Column("answer_d", String),
    Column("can_retry", Boolean, default = False)
)

现在我尝试插入一行:

i = quizzes.insert()
i.execute({   "subject": "Biology",
    "description": "Where is the heart?",
    "answer_a": "In the head",
    "answer_b": "In the arm",
    "answer_c": "In the gut",
    "answer_d": "Dunno",
    "can_retry": True
})

然而,当我发现subjectMathcan_retry0后我检查数据库时,即使我另外设置了它们。我究竟做错了什么?为什么即使我提供新的默认值,它仍然使用默认值?

0 个答案:

没有答案