Python Forum
Problem with updata the data into the database as it went into the wrong rows
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with updata the data into the database as it went into the wrong rows
#3
(Nov-11-2017, 12:50 AM)Larz60+ Wrote: you are running the inner loop with same data 10 times for each iteration of outer loop, why?

well I dont want to run the inner loop with same data 10 times.

When I try this:

     if value == program_id:
        cur.execute("UPDATE programs SET program_id=? WHERE start_date=?",(value, next_day))
It will insert the data into the database like 11 times:

Output:
    channel             |   start_date     |  program_id     101 BBC One South E |  20171111230000  |  3061     101 BBC One South E |  20171111233000  |  3062     101 BBC One South E |  20171112000000  |  3063     101 BBC One South E |  20171112013500  |  3064     101 BBC One South E |  20171112014000  |  3065     101 BBC One South E |  20171112060000  |  3066     101 BBC One South E |  20171112090000  |  3067     101 BBC One South E |  20171112102000  |  3068     101 BBC One South E |  20171112123000  |  3069     101 BBC One South E |  20171112133000  |  3070     101 BBC One South E |  20171112165500  |  3060     102 BBC Two         | 20171111232500   |     102 BBC Two         | 20171112010000   |       102 BBC Two         | 20171112023500   |       102 BBC Two         | 20171112060500   |       102 BBC Two         | 20171112065000   |       102 BBC Two         | 20171112073500   |       102 BBC Two         | 20171112083500   |       102 BBC Two         | 20171112093000   |       102 BBC Two         | 20171112130000   |       102 BBC Two         | 20171112140000   | 
Do you know how I can insert the 3001 to 3010 in the same rows as the next_day data??
Reply


Messages In This Thread
RE: Problem with updata the data into the database as it went into the wrong rows - by chris0147 - Nov-11-2017, 01:00 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  wrong entries in sqlite database and tkinter epsilondatum 2 461 Apr-23-2024, 04:48 PM
Last Post: epsilondatum
  how do you style data frame that has empty rows. gsaray101 0 562 Sep-08-2023, 05:20 PM
Last Post: gsaray101
  How to detect abnormal data in big database python vanphuht91 5 1,218 Jun-27-2023, 11:22 PM
Last Post: Skaperen
  Rows not adding to sqlite3 database using SQLAlchemy Calab 11 1,890 Jun-02-2023, 05:53 PM
Last Post: bowlofred
  Database that can compress a column, or all data, automatically? Calab 3 1,286 May-22-2023, 03:25 AM
Last Post: Calab
  Python Pandas Syntax problem? Wrong Output, any ideas? Gbuoy 2 977 Jan-18-2023, 10:02 PM
Last Post: snippsat
  (Python) Pulling data from UA Google Analytics with more than 100k rows into csv. Stockers 0 1,297 Dec-19-2022, 11:11 PM
Last Post: Stockers
  How to properly format rows and columns in excel data from parsed .txt blocks jh67 7 2,015 Dec-12-2022, 08:22 PM
Last Post: jh67
  Basic SQL query using Py: Inserting or querying sqlite3 database not returning data marlonbown 3 1,477 Nov-08-2022, 07:16 PM
Last Post: marlonbown
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,727 Nov-05-2022, 11:33 AM
Last Post: Mavoz

Forum Jump:

User Panel Messages

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