This is rather strange (itβs possible this is my first attempt with python / sqlite), but I may seem to get all the rows if I do fetchAll (), but other than that, whatever I try always ends in db. only returning the first line - the second iteration stops because null is returned. I wonder if something is wrong with how I code it in python? Db looks fine ..
con = sqlite3.connect('backup.db')
con.row_factory = sqlite3.Row
cur = con.cursor()
cur.execute('select * from tb1;')
for row in cur:
try:
print type(row)
print ' Starting on: %i' % row[0]
cleaner = Cleaner(scripts=True, remove_tags=['img'], embedded=True)
try:
cleaned = cleaner.clean_html(row[2])
cur.execute('update tb1 set data = ? where id = ?;', (cleaned, row[0]))
except AttributeError:
print 'Attribute error'
print ' Ended on: %i' % row[0]
except IOError:
print 'IOexception'
source
share