Web
Analytics
insert python variable values in database table | Angular | ASP.NET Tutorials

For Consultation : +91 9887575540

Stay Connected :

How to insert data in Table using Python

1.? Placeholder

2.Using python tuple and keyname placeholder

import sqlite3
db = sqlite3.connect('ganesha.db')
id1 = 1
name1= 'yogesh'
id2 = 2
name = 'vikas'
cursor = db.cursor()
# ? Placeholder
# cursor.execute('insert into info3(id,name) values(?,?)',(id1,name1))
cursor.execute('insert into info3(id,name) values(:id,:name)',{'id':id2,'name':name})

db.commit()