LiteSQL
Using Cursor

Often it is not necessary to fetch all objects to memory and then process them.

Memory usage can be minimized using template class Cursor which returns one object at a time.

Creating a cursor(two ways):

Cursor<Record> cur1 = db.cursor(SelectQuery().result("id_").source("Person_"));
Cursor<Person> cur2 = select<Person>(db).cursor();

Iterating through the result set:

for (;!cur.rowsLeft(); cur++)
cout << (*cur).name << endl;

The remaining contents of the result set can be retrieved with dump-method:

vector<Person> rest = cur.dump();

SourceForge.net Logo