Python Forum
Pymysql delete specific rows in tableview
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pymysql delete specific rows in tableview
#1
There is a database, data is constantly written to it, but sometimes data 0.0 gets. An entry appears in the table with values, for example prod1=0.0/ prod2=0.0/ prod3=0.0. And there can be a lot of such records in a day. I would like to make a python script that will be run by cron and delete all entries from 0.0. But there is data like: prod1=34.2/ prod2=0.0/ prod3=0.0 this line should be left.
Reply
#2
(Aug-18-2022, 08:15 AM)stsxbel Wrote: An entry appears in the table with values, for example prod1=0.0/ prod2=0.0/ prod3=0.0. And there can be a lot of such records in a day. I would like to make a python script that will be run by cron and delete all entries from 0.0. But there is data like: prod1=34.2/ prod2=0.0/ prod3=0.0 this line should be left.

To me, this is a contradiction: delete prod2=0.0 / prod3=0.0 but prod2=0.0 / prod3=0.0 should be left ??!!

I work with a SQL database every day and the best way to keep the data clean, is to not have any garbage written to it. As the saying goes: GIGO
Gribouillis likes this post
Sig:
>>> import this

The UNIX philosophy: "Do one thing, and do it well."

"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse

"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
Reply
#3
I agree with Rob101, it is best to prevent unwanted data to be written to the database.
But if this cannot be done, you will need to execute the following regularly.
delete from TABLENAME
where PROD1 = 0.0
  and PROD2 = 0.0
  and PROD3 = 0.0 ;

commit ;
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  delete specific row of entries jacksfrustration 3 1,276 Feb-13-2024, 11:13 PM
Last Post: deanhystad
  Reading Specific Rows In a CSV File finndude 3 1,847 Dec-13-2022, 03:19 PM
Last Post: finndude
  Mysql Syntax error in pymysql ilknurg 4 3,664 May-18-2022, 06:50 AM
Last Post: ibreeden
  Trying to delete rows above a specific datetime value cubangt 19 21,120 May-09-2022, 08:57 PM
Last Post: deanhystad
  The code I have written removes the desired number of rows, but wrong rows Jdesi1983 0 2,136 Dec-08-2021, 04:42 AM
Last Post: Jdesi1983
Question [SOLVED] Delete specific characters from string lines EnfantNicolas 4 3,244 Oct-21-2021, 11:28 AM
Last Post: EnfantNicolas
  pymysql can't do SELECT * Pedroski55 3 4,134 Sep-11-2021, 10:18 PM
Last Post: Pedroski55
  openpyxl incorrect delete rows VladislavM 6 6,125 Jul-19-2021, 08:54 AM
Last Post: VladislavM
  Pandas DataFrame combine rows by column value, where Date Rows are NULL rhat398 0 2,700 May-04-2021, 10:51 PM
Last Post: rhat398
  Indexing [::-1] to Reverse ALL 2D Array Rows, ALL 3D, 4D Array Columns & Rows Python Jeremy7 8 9,993 Mar-02-2021, 01:54 AM
Last Post: Jeremy7

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020