Python and SQLite: insert into table

后端 未结 6 640
梦如初夏
梦如初夏 2020-12-08 00:08

I have a list that has 3 rows each representing a table row:

>>> print list
[laks,444,M]
[kam,445,M]
[kam,445,M]

How to insert thi

6条回答
  •  一向
    一向 (楼主)
    2020-12-08 01:05

    there's a better way

    # Larger example
    rows = [('2006-03-28', 'BUY', 'IBM', 1000, 45.00),
            ('2006-04-05', 'BUY', 'MSOFT', 1000, 72.00),
            ('2006-04-06', 'SELL', 'IBM', 500, 53.00)]
    c.executemany('insert into stocks values (?,?,?,?,?)', rows)
    connection.commit()
    

提交回复
热议问题