I'm stuck on this error running the script below which goes through each column in my table and returns the max price for each. n.b. I've shortened the amount columns for this question.
import sqlite3
sqlite_file = 'foo.db'
conn = sqlite3.connect(sqlite_file)
c = conn.cursor()
column = ['AAC', 'AAD', 'ABC', 'ABP',
'AGL', 'AHG', 'AHY', 'AIO',
'ALL', 'ALQ', 'ALU', 'AMC']
for i in range(len(column)):
c.execute("SELECT max(%s) FROM prices" % (column[i]))
print (column[i], c.fetchall())
conn.close()
The script prints 8 results then I get the error?
Output:
AAC [('1.495',)]
AAD [('2.50',)]
ABC [('4.455',)]
ABP [('2.98',)]
AGL [('16.86',)]
AHG [('4.25',)]
AHY [('1.70',)]
AIO [('8.75',)]
sqlite3.OperationalError: wrong number of arguments to function max()
Please help!