2

I'm trying to dump a file from sqlite3 database using C++ function. I have tried this on terminal command and it works perfectly but here it's not executed.

errmsg=: no such function: writefile

bool Database::download(string username, string filename){

    string query = "SELECT USERNAME FROM FILES WHERE USERNAME='"+username+"';";
    int rc = sqlite3_exec(dbFile,query.c_str(),private_callback,(void *)data,&errmsg);
    if(rc==SQLITE_OK){
        cout<<"this username dont have any uploaded files!"<<endl;
        return false;

    }
    else{
        query = "SELECT writefile('"+filename+"',FILE) FROM FILES WHERE USERNAME='"+username+"' AND FILENAME='"+filename+"';";
        rc = sqlite3_exec(dbFile,query.c_str(),private_callback,(void *)data,&errmsg);

        if(rc!=SQLITE_OK){
            cout<<errmsg<<endl;
            return false;
        }
        elsereturn true;
    }
}
1

1 Answer 1

3

The documentation says:

Note that the readfile(X) and writefile(X,Y) functions are extension functions and are not built into the core SQLite library. These routines are available as a loadable extension in the ext/misc/fileio.c source file in the SQLite source code repositories.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.