2010-10-27 67 views
0

我有以下在Linux控制檯上正常工作的命令。但是爲了得到一個cpp文件的結果,我必須將它存儲到文件中然後讀取它。但是有沒有一種方法可以直接在C++中執行這個命令。如何在C++中執行SQLite語句

/usr/bin/sqlite3 /etc/myDB/db/share.db "select path from folder_info where ftp='YES'" 

回答

3

據我理解你的問題,你可以使用SQLite3的Ç被描述here

+0

您還可以查看該演示項目(它'窗戶,但它會得到的總體思路) - http://www.codeproject.com/KB/database/CppSQLite.aspx – lexa78 2010-10-27 09:15:51

+0

你也可以在C++中使用C API進入sqlite。 – MarkR 2010-10-27 09:35:53

1

我怎樣才能在C++

使用stringstream執行一個SQLite聲明++ API

An Introduction To The SQLite C/C++ Interface

sqlite3 *db; 
    sqlite3_open("dbfile.db", &db); 
    sqlite3_stmt *companydetails; 
    std::stringstream companystr; 
    companystr << "select companyname,companydetails from company"; 
    sqlite3_prepare(db, companystr.str().c_str(), companystr.str().size(),&companydetails, NULL); 
    sqlite3_step(companydetails); 
相關問題