I am using python 3.7 and sqlite3 to write data to my database. I have this function
def add_item(self, item):
stmt = "INSERT INTO users (id) VALUES (?)"
args = (item,)
self.conn.execute(stmt, args)
self.conn.commit()
It works fine but it only allows me to write data to id column. How can I make this function dynamic so that I can add any data to any column?
# new variable to specify column to write to
def add_item(self, item, column):
stmt = "INSERT INTO users (column) VALUES (?)"
args = (item,)
self.conn.execute(stmt, args)
self.conn.commit()