【发布时间】:2020-06-08 06:53:33
【问题描述】:
我有一个 SQLite 数据库,它有一个表,其中包含一些 BLOB 类型的字段。 我要做的是从数据库中获取字段(实际上也是所有其他字段)到 C++ 中,通过 protobuf 发送并接收 protobuf。
我在 .proto 文件中将 blob 字段定义为 bytes
例如
message fields{
...
bytes myBlobField = 1;
}
我的 c++ 文件包含
sqlite3_initialize();
rc = sqlite3_open_v2(db_url, &db,SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,NULL);
std::ostringstream oss;
oss << "select * from attribtable ";
std::string query = oss.str();
rc = sqlite3_prepare_v2(db,query.c_str(),-1,&stmt,NULL
while(sqlite3_step(stmt) == SQLITE_ROW){
sqlite3_column_blob(stmt,10) //This is the blob field
}
如何在 C++ 中存储 sqlite3_column_blob(stmt,10) 以及如何设置 myBlobField 使用
说reply->set_myblobfield(??)
并使用在客户端接收
say receive->get_myblobfield()
简而言之,我的问题是如何在 C++ 应用程序中将通过 protobuf 从数据库中获取的 blobfield 从服务器发送到客户端?
【问题讨论】:
-
fields预处理成什么? -
@RichardCritten 你能更清楚地说明你想问的问题吗?
标签: c++ blob protocol-buffers grpc proto