How to insert variable into sqlite database in python?

前端 未结 3 1402
抹茶落季
抹茶落季 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:53

    I found this example for inserting variables to be very helpful.

    c.execute("SELECT * FROM {tn} WHERE {idf}={my_id}".\
            format(tn=table_name, cn=column_2, idf=id_column, my_id=some_id))
    

    Here's the link to the tutorial. http://sebastianraschka.com/Articles/2014_sqlite_in_python_tutorial.html

提交回复
热议问题