dbTalk Databases Forums  

Storing BLOB using C constructs and no STL(string, streams etc)

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Storing BLOB using C constructs and no STL(string, streams etc) in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ankur G35 Saxena
 
Posts: n/a

Default Storing BLOB using C constructs and no STL(string, streams etc) - 11-19-2006 , 02:18 PM






Hi,

I need help in convertin this piece of code in C strings rather than
streams and strings. can someone please help me out with the use of
escape in char*.

c_struct is a C structure with some char buffers and int values.

string fill((char*)c_struct, len);

setQ << "UPDATE Info.Paid SET InfoStruct=\""
<< mysqlpp::escape << fill << "\" WHERE ID='" << val_chk << "'" << ends;

Thanks.
Ankur

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
Warren Young
 
Posts: n/a

Default Re: Storing BLOB using C constructs and no STL(string, streams etc) - 11-20-2006 , 10:57 AM






Ankur G35 Saxena wrote:
Quote:
I need help in convertin this piece of code in C strings rather than
streams and strings. can someone please help me out with the use of
escape in char*.

c_struct is a C structure with some char buffers and int values.

string fill((char*)c_struct, len);
This is very poor practice. It will break if you:

- change certain compiler options

- change compiler vendors

- change CPU types (including 32-bit to 64-bit)

- use different compilers or build options on multiple machines
accessing the same database

- change the slightest thing about the definition of c_struct

This code is crying out for c_struct to be a SSQLS. Then the "how"
becomes obvious.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
Ankur G35 Saxena
 
Posts: n/a

Default Re: Storing BLOB using C constructs and no STL(string, streams etc) - 11-20-2006 , 02:15 PM



On 11/20/06, Warren Young <mysqlpp (AT) etr-usa (DOT) com> wrote:
Quote:
Ankur G35 Saxena wrote:

I need help in convertin this piece of code in C strings rather than
streams and strings. can someone please help me out with the use of
escape in char*.

c_struct is a C structure with some char buffers and int values.

string fill((char*)c_struct, len);

This is very poor practice. It will break if you:

- change certain compiler options

- change compiler vendors

- change CPU types (including 32-bit to 64-bit)

- use different compilers or build options on multiple machines
accessing the same database

- change the slightest thing about the definition of c_struct

This code is crying out for c_struct to be a SSQLS. Then the "how"
becomes obvious.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...mail (DOT) com



Ok fine I agree, now if this was an image I was trying to read of the
FS, then what? its a char buffer, now how do I put this in query
without having to create a string? Some piece of code, assuming I have
a buffer called img_buf which is char[4096] that I want to put in?

Thanks

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #4  
Old   
Warren Young
 
Posts: n/a

Default Re: Storing BLOB using C constructs and no STL(string, streams etc) - 11-20-2006 , 02:48 PM



Ankur G35 Saxena wrote:
Quote:
Ok fine I agree, now if this was an image I was trying to read of the
FS, then what?
Well, personally, I prefer to store images outside the database. I
think big BLOBs are a bad fit with the way database servers are designed
to be used.

But if you're asking how, generally, do you do BLOBs in MySQL++, the
answer is in examples/load_image.cpp.

Yes, this can be better, which is what most of the Wishlist items for
the next version or two are about. If you want them to appear faster,
provide a patch.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.