Postgresql: How to delete rows from table constrained by date?

Robert

I am using psycopg2 and how can I delete rows that are older than a certain date? For example:

cursor.execute('DELETE FROM datatable WHERE date < %s', datetime.date(2012, 1, 1))

If I write like this, there will be TypeError: 'datetime.date' object does not support indexing. How can I do with it? Thanks!

falsetru

Pass the second argument as a list or a tuple:

cursor.execute('DELETE FROM datatable WHERE date < %s', [datetime.date(2012, 1, 1)])

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Postgresql: How to delete rows from table constrained by date?

From Dev

Delete Rows from a Constrained Reference Table

From Dev

How to delete from table then delete what deleted rows referenced? (postgresql)

From Dev

how to delete fixed number of rows from a table with null values in PostgreSQL

From Dev

Postgresql: how to set the date in all rows of table?

From Dev

How to delete some similar rows from a table?

From Dev

Delete rows from table

From Dev

How to Use Delete Triggers to Delete Rows From Same Table?

From Dev

How to delete a table in postgresql

From Dev

How to count rows using a variable date range provided by a table in PostgreSQL

From Dev

How to delete rows from a table based on a join with another table?

From Dev

How to delete rows from one table matching another table?

From Dev

Delete X rows from table

From Dev

PostgreSQL DELETE FROM (SELECT * FROM table FETCH FIRST 10 ROWS ONLY)

From Dev

How to delete unknown number of rows from sql table

From Dev

How to quickly delete a column from a table containing 600 million rows?

From Dev

How to delete many rows from frequently accessed table

From Dev

How To Delete Rows From Temp Table With EntityDelete In CFSCRIPT

From Dev

How to delete all rows from table which has no FK relation

From Dev

How to delete rows from table when clicking button

From Dev

How do I delete multiple rows from a table on Backand?

From Dev

How can I delete multply rows from a table with another condition?

From Dev

How to efficiently delete expired rows from a large MySQL table

From Dev

Postgresql delete multiple rows from multiple tables

From Dev

How to count rows from a different table based on same date range

From Dev

From a table of made up of rows of dates, how to count the number of rows where the date is in a certain date range

From Dev

How to delete rows depending on the previous column - postgresql

From Dev

How to delete rows on table when date column is already past 2 days?

From Dev

how to delete selected rows (multiple rows) from CheckboxTableViewer when button clicks? (table is connected to oracle database)

Related Related

  1. 1

    Postgresql: How to delete rows from table constrained by date?

  2. 2

    Delete Rows from a Constrained Reference Table

  3. 3

    How to delete from table then delete what deleted rows referenced? (postgresql)

  4. 4

    how to delete fixed number of rows from a table with null values in PostgreSQL

  5. 5

    Postgresql: how to set the date in all rows of table?

  6. 6

    How to delete some similar rows from a table?

  7. 7

    Delete rows from table

  8. 8

    How to Use Delete Triggers to Delete Rows From Same Table?

  9. 9

    How to delete a table in postgresql

  10. 10

    How to count rows using a variable date range provided by a table in PostgreSQL

  11. 11

    How to delete rows from a table based on a join with another table?

  12. 12

    How to delete rows from one table matching another table?

  13. 13

    Delete X rows from table

  14. 14

    PostgreSQL DELETE FROM (SELECT * FROM table FETCH FIRST 10 ROWS ONLY)

  15. 15

    How to delete unknown number of rows from sql table

  16. 16

    How to quickly delete a column from a table containing 600 million rows?

  17. 17

    How to delete many rows from frequently accessed table

  18. 18

    How To Delete Rows From Temp Table With EntityDelete In CFSCRIPT

  19. 19

    How to delete all rows from table which has no FK relation

  20. 20

    How to delete rows from table when clicking button

  21. 21

    How do I delete multiple rows from a table on Backand?

  22. 22

    How can I delete multply rows from a table with another condition?

  23. 23

    How to efficiently delete expired rows from a large MySQL table

  24. 24

    Postgresql delete multiple rows from multiple tables

  25. 25

    How to count rows from a different table based on same date range

  26. 26

    From a table of made up of rows of dates, how to count the number of rows where the date is in a certain date range

  27. 27

    How to delete rows depending on the previous column - postgresql

  28. 28

    How to delete rows on table when date column is already past 2 days?

  29. 29

    how to delete selected rows (multiple rows) from CheckboxTableViewer when button clicks? (table is connected to oracle database)

HotTag

Archive