db = UnQLite('test.db')
data = db.collection('data')
print(data.fetch(0))
This works.
Now, how do I fetch each record and extract the necessary fields from it?
I am looking for something like
db = UnQLite('test.db')
data = db.collection('data')
for i in range(data.size()???)
print(data.fetch(i))
There isn't any size() method on the collection. Any help is appreciated.
A collection is itself iterable:
for record in data:
# use record
# to save changes:
data.update(record['__id'], record)
data.reset_cursor() # if you want to iterate again
len () Return the number of records in the database.
Warning: This method calculates the lengthy by iterating and counting every record. At the time of writing, there is no C API for calculating the size of the database.
for i in range(0,len(data)):
print data[i]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.