You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Greetings! I have a small suggestion: in the course of using the library I discovered that I wasn't able to use the get_col_from_db(..) methods for accessing individual columns in a multi-row setting.
I added a step() function which solved the issue for me. I'm new to this library so I'm not sure if there's another way to achieve the same thing but I figured I'd shared the snippet I wrote:
bool step() {
if (!used()) {
_start_execute();
}
int hresult = sqlite3_step(_stmt.get());
if ( hresult == SQLITE_ROW ) {
return true;
}
else if (hresult != SQLITE_DONE ) {
errors::throw_sqlite_error(hresult, sql());
return false; // Need unreachable return to make "not all paths" error go away
}
else {
return false;
}
}
The workflow I'm using is:
auto selectStmnt = *_db << ss.str();
TestDBClass fromDb;
while ( selectStmnt.step() ) {
mapper.deserialize(selectStmnt, fromDb);
// Decided whether to continue parsing other rows here or to break out
}
// selectStmnt goes out of scope and gets cleaned up automatically
Like I said earlier, perhaps there's already a built-in method which I'm not aware of and in that case if you could point me in the right direction I'd be much obliged. Thanks!
The text was updated successfully, but these errors were encountered:
@aminroosta The change would be easy. The iterators on the dev branch also allow something quite near to the proposed while:
for(auto &&row : db << "select age,name,weight from user where age > ? ;" << 21) {
// Do something with `row`, for example
string name; int age;
row >> name >> age;
cout << name << ": " << age << '\n';
if(something) break; // maybe stop extracting the remaining rows.
}
Greetings! I have a small suggestion: in the course of using the library I discovered that I wasn't able to use the get_col_from_db(..) methods for accessing individual columns in a multi-row setting.
I added a step() function which solved the issue for me. I'm new to this library so I'm not sure if there's another way to achieve the same thing but I figured I'd shared the snippet I wrote:
The workflow I'm using is:
Like I said earlier, perhaps there's already a built-in method which I'm not aware of and in that case if you could point me in the right direction I'd be much obliged. Thanks!
The text was updated successfully, but these errors were encountered: