我如何将char数据直接保存到blob db?

时间:2017-10-21 10:03:05

标签: c++ sqlite blob

我需要将一个wxBitmap保存到SQLite到blob类型而不保存到磁盘或某些媒体上。 我有mybitmap作为wxBitmap; 首先必须转换为wxImage并获取数据。 好的,直到现在我希望,但我如何将char数据直接保存到blob db? 在sql中必须有

  

更新mytable SET blob_column =' ??????' WHERE id =' 1'

或类似的东西。如何构建查询?

wxImage img=mybitmap.ConvertToImage();
unsigned char* data=img.GetData();
int datalength=img.GetWidth()*img.GetHeight()*3;
char *myBuffer = (char *)data;

以下代码适用于wxSQLite3 ...

    wxMemoryOutputStream mo;
img.SaveFile( mo, wxBITMAP_TYPE_PNG );

wxSQLite3Statement stmt = db.PrepareStatement("UPDATE mytable SET blob_column='?' WHERE id='1'");
stmt.Bind(0, (unsigned char *)mo.GetOutputStreamBuffer()->GetBufferStart(), mo.GetOutputStreamBuffer()->GetBufferSize());
stmt.ExecuteUpdate();

但是如何翻译SQLite?

0 个答案:

没有答案