question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[enhancement] Method to delete a row in python

See original GitHub issue

Hi ! 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:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
simonwcommented, Nov 4, 2019

Released as 1.12.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found