使用限制插入SQLite数据库

时间:2016-07-03 22:35:34

标签: python python-2.7 sqlite

我的代码需要一些帮助。我想用限制数据为每个通道的每行写入数据到数据库中。

当我尝试这个时:

#store the id and width of buttons in a database
for button_id, prog_width in zip(program_id, program_width):
    cur.execute("INSERT INTO buttons(button_ids, button_width)" + " VALUES(?, ?)", [button_id, prog_width])[/code]

它会在一个通道中的每一行中插入数据。我想在每个通道的每一行中插入数据。我在数据库中有7个频道。

我为每个频道提供了10个button_idprogram_width的数据,因此每个频道的button_id(每个频道10个数据)和program_width 10个数据的总数据)是70.我存储在数据库中的每个通道有120个数据。代码将做的是它们将在一个通道中插入前70行以插入错误的70个数据。我希望代码为每个通道插入button_id的10个数据,然后为下一个通道插入下10个数据,依此类推。

我已经尝试过这个:

cur5.execute("INSERT INTO buttons(button_ids, button_width) LIMIT 10" + " VALUES(?, ?)", [button_id, prog_width])

它会给我一个错误: OperationalError:接近“LIMIT”:语法错误

请举例说明如何在每个频道的每一行插入数据,限制为10?

0 个答案:

没有答案
相关问题