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

标签 c++ sqlite dump

我正在尝试使用C++函数从sqlite3数据库中转储文件。
我已经在终端命令上尝试过了,它可以正常工作,但是这里没有执行。

errmsg =:
没有这样的功能: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.

关于c++ - 如何使用C++在sqlite3数据库中执行writefile函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50821273/

相关文章:

c++ - 在 Ubuntu QT 上构建时出现 'QMetaObject::connectSlotsByName: No matching signal for' 错误

c++ - 在 linux 中使用 win32 api?

android - Android SQLite 和数据库架构上的 ORM

windbg - 使用 WinDbg 和 SOS : How do I get the urls of all currently executing requests? 分析转储文件

c++ - 如何将 char 类型数组传递给函数并将第一个 char 数组复制到第二个图表数组并使用 C++ 进行比较?

javascript - 从 sqlite 查询 Node.js 中检索数据

python - Django 2.0 : sqlite IntegrityError: FOREIGN KEY constraint failed

c++ - 在 C++ 中转储十六进制 float

python - 如何在 python 中使用 json 将包含用户定义类的字典转储为值?

c++ - ‘operator->()’ 的结果产生非指针结果