如何使用C++在sqlite3数据库中执行writefile函数

How to execute writefile function in sqlite3 database using C++

我正在尝试使用 C++ 函数从 sqlite3 数据库转储文件。 我已经在终端命令上试过了,它运行良好,但这里没有执行。

错误信息=: 没有这样的函数: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;
    }
}

documentation 说:

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.