I have problem with sqlite3 in Python. I want sorting data from database by inputing date.
Here is my code, is it good way?
if choice == 1:
# Suma 'Wartość' z simple.db
dt = input()
dt2 = input()
cursor.execute('''
SELECT
SUM(Wartość),
Data
FROM
kalendarz
WHERE
Data between () and () VALUES (?, ?);''', (dt, dt2))
CodePudding user response:
you are summing the column Wartość
without group by try this instead:
if choice == 1:
dt = input()
dt2 = input()
cursor.execute(f'''
SELECT
Wartość,
Data
FROM
kalendarz
WHERE
Data between '{dt}' and '{dt2}'
ORDER BY
Data''')