[enhancement] Method to delete a row in python
See original GitHub issueHi ! Thanks for the lib !
Obviously, every possible sql queries won’t have a dedicated method.
But I was thinking : a method to delete a row (I’m terrible with names, maybe delete_where()
or something, would be useful.
I have a Database, with primary key.
For the moment, I use :
db.conn.execute(f"DELETE FROM table WHERE key = {key_id}")
db.conn.commit()
to delete a row I don’t need anymore, giving his primary key.
Works like a charm.
Just an idea :
table.delete_where_pkey({'key': key_id})
or something (I know, I’m terrible at naming methods…).
Pros : well, no need to write SQL query.
Cons : WHERE normally allows to do many more things (operators =, <>, >, <, BETWEEN), not to mention AND, OR, etc… Method is maybe to specific, and/or a pain to render more flexible.
Again, just a thought. Writing his own sql works too, so…
Thanks again. See yah.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Delete Rows & Columns in DataFrames using Pandas Drop
The pandas drop function can delete rows based on numeric or text based indices on python. Indices are, by default, incrementing integers when...
Read more >How to delete a row from csv file using del function
One approach is to write the content to a temp file and then rename it. Ex: import csv import os with open('grades.csv', 'r')...
Read more >Edit and Delete Rows - Anvil Works
Usually you'll want to allow editing the data and deleting rows entirely as well. In this tutorial, we'll modify the Data Grid to...
Read more >Python | Delete rows/columns from DataFrame using Pandas ...
Pandas provide data analysts a way to delete and filter data frame using .drop() method. Rows or columns can be removed using index...
Read more >Bulk-delete Data | CockroachDB Docs
To delete a large number of rows (i.e., tens of thousands of rows or more), we recommend iteratively deleting subsets of the rows...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Released as 1.12.
Documentation for
.delete_where()
: https://github.com/simonw/sqlite-utils/blob/169ea455fc1f1d5e5b6e44cb339ba7ffa9d49c31/docs/python-api.rst#deleting-multiple-records