Sqlite3 terminates INSERT without error

0

In my code I execute a loop where I download some images from a URL and then save the image name in sqlite3 , however after a few% with% the code simply ignores the line where it is the inserts .

if hasattr(card, 'image_url'):
    print("Downloading card: " + card.name)
    card_image = 'images/' + card.set + '/' + card.name + '.jpg'

    if not card.image_url == None:
       try:
           urllib.request.urlretrieve(card.image_url, card_image)
       except (HTTPError, URLError) as error:
           print('Erro na URL, continuando...')
       except timeout:
           print('Time out atingido, continuando...')

    card_subtype = '|'.join(card.subtypes) if isinstance(card.subtypes, (list)) else card.subtypes
    card_color = '|'.join(card.colors) if isinstance(card.colors, (list)) else card.colors

    cursor.execute('INSERT INTO cards VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [None, card.name, None, card.multiverse_id, str(card.type), card_subtype, card_color, card.rarity, card.mana_cost, card.power, card.toughness, card.set, card.text, card.flavor, card_image])

    print('Saving card: ' + card.name)
    connection.commit()
    print('Saved.')

The amount saved was 1231 records, and then only the first print runs, (downloading card ...) and the other 2 at the end of the code are ignored.

    
asked by anonymous 16.01.2017 / 14:29

0 answers