List:MySQL++« Previous MessageNext Message »
From:John Gehring Date:November 19 2007 3:04pm
Subject:Re: How to insert binary data from an array of bytes
View as plain text  
I pass a char* (charData) containing my binary data into my insert routine
along with the size of the binary data. Then;

string blobData;
blobData.assign(charData, size);
mysqlpp::Query query = mySQLconn.query();
query << "insert into table (fieldname) values (";
query << ",\"" << mysqlpp::escape << blobData << "\")";
query.execute();

This may not be the most elegant use of mysqlpp, but it works.



On Nov 19, 2007 5:03 AM, António Santos <ansantos@stripped> wrote:

> Hi,
>
> I'm having some difficulties in inserting binary data to mysql.
> I have an array of bytes (unsigned char[]) and I want to insert those
> bytes into a table.
> How can I do that? The provided example doesn't help me that much
> because it uses binary data read from a file.
>
> Thanks,
>
> António Santos
>
>
>
> --
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe:
> http://lists.mysql.com/plusplus?unsub=1
>
>

Thread
How to insert binary data from an array of bytesAntónio Santos19 Nov
  • Re: How to insert binary data from an array of bytesJohn Gehring19 Nov
  • Re: How to insert binary data from an array of bytesWarren Young19 Nov