sqlite_modern_cpp icon indicating copy to clipboard operation
sqlite_modern_cpp copied to clipboard

Invalid range expression of type 'database_binder'; no viable 'begin' function available

Open andriy-byte opened this issue 1 year ago • 3 comments

the code from README

        for(auto &&row : db << "select age,name,weight from user where age > ? ;" << 18) {
            int age; string name; double weight;
            row >> age >> name >> weight;
            cout << age << ' ' << name << ' ' << weight << endl;
        }
        // or with a tuple
        for(tuple<int, string, double> row : db << "select age,name,weight from user where age > ? ;" << 18) {
            cout << get<0>(row) << ' ' << get<1>(row) << ' ' << get<2>(row) << endl;
        }

I recived the problem

Invalid range expression of type 'database_binder'; no viable 'begin' function available

at : operator in both foreach loops

andriy-byte avatar Apr 01 '23 18:04 andriy-byte

I am also experiencing the same issue

thevojacek avatar May 12 '23 11:05 thevojacek

having the same issue

codethinki avatar Dec 15 '23 18:12 codethinki

okay i found the SOLUTION:

apparently the default branch is "/dev" (so the readme is from that branch) and the latest release is not up to date. Therefore, for anyone who is downloading releases with package managers or manually, the range-based stuff is not going to work.

Instead:

clone the dev branch with git and then include the header manually.

Git command for anyone lazy :) git clone --branch dev https://github.com/SqliteModernCpp/sqlite_modern_cpp

codethinki avatar Dec 15 '23 19:12 codethinki