List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:November 19 2007 7:25pm
Subject:Re: How to insert binary data from an array of bytes
View as plain text  
António Santos wrote:
> 
> I have an array of bytes (unsigned char[]) and I want to insert those 
> bytes into a table.

I would first examine whether this is the best table design. 
Array-of-anything should almost always map to rows in a separate table, 
not a column containing N values.  It's a one-to-many relationship, one 
of the main reasons databases can hold multiple tables.

> The provided example doesn't help me that much 
> because it uses binary data read from a file.

examples/load_jpeg.cpp doesn't insert a file into the database, it 
inserts a std::string into the database, and a std::string is just a 
fancy way to hold an array of characters.  The fact that the string 
happens to be populated from a file in this case is incidental.
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