How to insert variable into sqlite database in python?

前端 未结 3 1489
抹茶落季
抹茶落季 2020-12-16 06:27

My code seems to run fine without any errors but it just creates an empty database file with nothing in it, Cant figure out what i\'m doing wrong here.

impor         


        
3条回答
  •  暖寄归人
    2020-12-16 06:43

    The reason that your database file is becoming blank isn't because your varbiables aren't inserted into your SQL syntax properly. Its because of what you did here cur.commit(). You're not meant to commit your cursor to save any changes to the database. You're meant to apply this attribute to the variable in which you've connected to your database file. So in your case, it should be con.commit()

    Hope this helps :)

提交回复
热议问题