Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8481741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:38:29+00:00 2026-06-10T19:38:29+00:00

EDIT: ANSWER: I needed to create another cursor for the ‘einlesen()’ function. This is

  • 0

EDIT:
ANSWER: I needed to create another cursor for the ‘einlesen()’ function.

This is my first time using SQLite3 in Python, so excuse my (maybe) horrible syntax 😉
I’m trying to build kind of a DVD-Database, which fetches necessary information (actors etc.) directly from amazon. The whole program is based upon SQLite3 and Python 2.7.

Everything works well, except my plannes “update” feature.

def update():
    print 'Update Datenbank....bitte warten....'
    cursor.execute('''SELECT titel, amazon, erhalten, ausgeliehen FROM movies''')
    antwort = 'update'
    for row in cursor:
        stelle = row[1]
        ausg = row[2]
        erh = row[3]
        einlesen(stelle, ausg, erh, antwort)
        print row[0]
    raw_input('Update komplett!')
    menu()

The problem is, the loop exits after one iteration.

The output looks like this:

Update Datenbank....bitte warten....
#a few seconds pass
The Day After Tommorrow
Update komplett!

So I see, the loop and the function call are correct (the database gets updated correctly – done by the function ‘einlesen()’), but there are more iterations, not just one…
So my question is: What is wrong? 😉

Here is the (abbreviated) ‘einlesen()’ function:

def einlesen(asin, ausg, erh, antwort):
    d = {}
    infos = urllib.urlopen('http://www.amazon.de/dp/'+asin).read()
    titel = infos[infos.find('Kaufen Sie')+11:infos.find('nstig ein')-3]
    art = 'dvd'
    infos = remove_html_tags(infos)
    infos = infos[infos.find('Darsteller: '):infos.find('Durchschnittliche')]
    infos = infos.split('\n')
    for x in range(200):
        try:
            infos.remove('')
        except:
            break
    for element in infos:
            d[element.split(': ')[0].lstrip()] = element.split(': ')[1]

#(excluded the whole Info-Scraping process)

    if antwort == 'update':
        movie = dauer, art, regie, jahr, fsk, darsteller, titel
        sql = ('''UPDATE movies SET laufzeit = ?, art = ?, regie = ?, jahr = ?, fsk =     ?, darsteller = ? WHERE titel = ?''')
        cursor.execute(sql, movie)
        connection.commit()
    else:
        menu()

Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:38:31+00:00Added an answer on June 10, 2026 at 7:38 pm

    Your execute an UPDATE while you are still looping over the result of the SELECT. This drops the result of the first cursor.execute().

    Use a second cursor.

    Edit:

    cur1 = con.cursor()
    cur2 = con.cursor()
    
    cur1.execute("SELECT ...")
    for row in cur1:
        cur2.execute("UPDATE ...")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT : Accepted answer points out what my issue was. I added another answer
Answer solved in edit below I had this piece of code Dictionary<Merchant, int> remaingCards
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
EDIT: See my answer below--> I am wanting to have a view that when
[Edit] I've summarized the answer to the following below, the error lies in the
FINAL EDIT: After following the answer from Darin Dimitrov, I have found that the
EDIT: I figured it out from Bergi's answer in the end. Thanks Bergi. pubPrivExample
[EDIT] I am NOT accepting any answer which involves BigInteger, or other similarly inefficient
Edit: Building off of aL3xa's answer below, I've modified his syntax below. Not perfect,
EDIT 23-06-2012 10:24 (CET) : Found the answer Take a look at the bottom

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.