0

This is my data base

I want to delete all the dates with day 26, for example But code like this doesn't work:

CURSOR.execute(f"SELECT * FROM {name}_schedule WHERE date == {date}")

I do not know sql at all, so idk what to do :c

Barmar
  • 741,623
  • 53
  • 500
  • 612
PR. OR
  • 1
  • 2
  • `SELECT` doesn't delete anything, it returns the contents of those rows. Use `DELETE` to delete rows. – Barmar Jul 27 '23 at 19:59
  • Use a placeholder instead of `{date}`. See https://stackoverflow.com/questions/902408/how-to-use-variables-in-sql-statement-in-python – Barmar Jul 27 '23 at 19:59
  • The problem with your query is that you need quotes around `{date}`. But if you use a prepared statement as in the above link, you won't have that problem. – Barmar Jul 27 '23 at 20:00

1 Answers1

0

The sql could be something like this

DELETE FROM table_name WHERE strftime('%d', date_column) = '26'
Itulf
  • 16