ich habe gerade ein kleines Testprogram geschrieben, um die Möglichkeiten von Sqlite mit binären Daten zu testen:
Code: Alles auswählen
#include <iostream>
#include <sqlite3.h>
#include <boost/filesystem.hpp>
int main (void)
{
sqlite3 *db;
sqlite3_stmt *stmt=0;
boost::filesystem::path DbPath( "test.db" );
sqlite3_open(DbPath.c_str(), &db);
boost::filesystem::path Pfad( "ööei/ieie'" );
std::string Sql( "INSERT INTO dbtable VALUES( ? );");
sqlite3_prepare_v2( db, Sql.c_str(), Sql.size(), &stmt, 0 );
sqlite3_bind_blob(stmt, 1, reinterpret_cast<const void*>(&Pfad), sizeof( boost::filesystem::path),SQLITE_TRANSIENT);
sqlite3_step( stmt );
sqlite3_finalize( stmt );
Sql = "SELECT * From dbtable WHERE blobfield=(?);";
sqlite3_prepare_v2( db, Sql.c_str(), Sql.size(), &stmt, 0 );
sqlite3_bind_blob(stmt, 1, reinterpret_cast<const void*>(&Pfad), sizeof( boost::filesystem::path),SQLITE_TRANSIENT);
sqlite3_step( stmt );
//std::cout << sqlite3_column_name( stmt, 0) << std::endl;
const void * ptr(NULL);
boost::filesystem::path *pptr(NULL);
ptr = sqlite3_column_blob( stmt, 0 );
pptr = reinterpret_cast<boost::filesystem::path*>(&ptr);
sqlite3_finalize( stmt );
sqlite3_close( db );
std::cout << Pfad << std::endl;
std::cout << *pptr << std::endl;
return 0;
}