I am new to coding.
I am trying to get output from deducting one column from another in one table.
The result/output I get is used to update another column in the table.
code
import sqlite3
ebook = sqlite3.connect(‘bookstore.db’)
cursor = ebook.cursor()
mar_results = ”’SELECT ts_sp, ts_pp,(ts_sp – ts_pp) AS mar_rusults FROM book WHERE b_id = 3001”’
cursor.execute(mar_results,)
mar_results = cursor.fetchall()
cursor.execute(”’UPDATE book SET ts_margin = ? WHERE b_id = 3001 ”’, (margin_results,))
ebook.commit()
what I expected to see is the 54.0 in the TS_margin column:
ts_sp ts_pp ts_margin
139.0 85.0 54.0
I am getting the below error:
cursor.execute(”’UPDATE book SET ts_margin = ? WHERE b_id = 3001 ”’, (margin_results,))
sqlite3.ProgrammingError: Error binding parameter 1: type ‘tuple’ is not supported
Thanks in advance for the help
user24820062 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.