1
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.

Gayatri
  • 152
  • 3
  • 12

2 Answers2

0

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
Douglas Leeder
  • 52,368
  • 9
  • 94
  • 137
-1

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]
dekk
  • 1
  • 1