c++;Mysql在数据库中保存二进制blob 所以我在Ubuntu 64位机上使用G++和Mysqlcppconn(MySQL C++连接器)。我想将二进制数据块插入数据库并能够检索它。 视网膜 typedef unsigned char byte; byte data[512]; istream *buf=res->getBlob(1); buf->read((char*)data,512);
我只是希望这能奏效,但我不太确定。这是一个结果集 为了存储在数据库中,我不知道如何将字节*转换为istreamc++;Mysql在数据库中保存二进制blob 所以我在Ubuntu 64位机上使用G++和Mysqlcppconn(MySQL C++连接器)。我想将二进制数据块插入数据库并能够检索它。 视网膜 typedef unsigned char byte; byte data[512]; istream *buf=res->getBlob(1); buf->read((char*)data,512);,c++,mysql,mysql-connector,C++,Mysql,Mysql Connector,我只是希望这能奏效,但我不太确定。这是一个结果集 为了存储在数据库中,我不知道如何将字节*转换为istream Thanx用于读取。答案在于使用流缓冲区在数据库中写入blob struct membuf: std::streambuf { membuf(char* b, char* e) { this->setg(b, b, e); } }; byte *p = something....; membuf buf((char*)p,(char*)p+ALPHABET_SIZE*s
Thanx用于读取。答案在于使用流缓冲区在数据库中写入blob
struct membuf: std::streambuf
{
membuf(char* b, char* e) { this->setg(b, b, e); }
};
byte *p = something....;
membuf buf((char*)p,(char*)p+ALPHABET_SIZE*sizeof(ull));
istream is(&buf);
ps->setBlob(1,&is);
这是一份准备好的声明:)