This is pretty strange (admitedly, this is my first attempt with python / sqlite), but I can seem to get all of the rows if I do a fetchAll(), but other than that - no matter what I try, always ends up in the db only returning the first row - the second iteration stops because a null is returned. Wondering if there is something wrong with how I am coding this up in python? The db seems ok..
con = sqlite3.connect('backup.db')
con.row_factory = sqlite3.Row
cur = con.cursor()
cur.execute('select * from tb1;')
for row in cur:
try:
# row = dataCur.fetchone()
#if row == None: break
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]) #data stored in second col
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'
SQLite is used to develop embedded software for devices like televisions, cell phones, cameras, etc. It can manage low to medium-traffic HTTP requests. SQLite can change files into smaller size archives with lesser metadata. SQLite is used as a temporary dataset to get processed with some data within an application.
SQL is Structured Query Language which is used with databases like MySQL, Oracle, Microsoft SQL Server, IBM DB2, etc. It is not a database itself. SQLite is a portable database resource. You have to get an extension of SQLite in whatever language you are programming in to access that database.
Both MySQL and SQLite are forms of a Relational Database Management System (RDBMS). These are based on the Structured Query Language (SQL).
All data is handled inside your process solely for your application. SQLite is generally a lot faster than MS SQL Server if dealing with small-size databases. SQLite can be integrated with different programming languages and environments including . NET.
You are reusing the same cursor to execute two different queries. Try using two different cursors and see if that solves your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With