dbTalk Databases Forums  

problems storing files in blobs

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


Discuss problems storing files in blobs in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Thomas Werth
 
Posts: n/a

Default problems storing files in blobs - 01-13-2006 , 07:09 AM






Hi,

i'm using mysqlpp 2.0.6
I'm trying to store an image in a blob. Unfortunatly from time to time i
get sql-syntax error when file content contains " or ' or similar.

Here's what i'm doing

buffer contains char * read from file

std::string fill ( buffer, file_size );
mysqlpp::escape_string( fill );
delete [] buffer;

sql << "INSERT INTO zzzBlobTest ( Filename , Content ) VALUES ( \"";
sql << filename4DB;
sql << "\", \"";
sql << mysqlpp::escape;
sql << fill;
sql << "\" )";
sql << std::ends;
//now call wrapper func for executing
fileID = mySqlAdapter.executeInsert ( sql.str(), true, false );

//Func def comes here
/**
führt einen Insert Befehl aus und liefert die Insert ID
*/
int CMySqlConnector::executeInsert( std::string sql, const bool log,
bool replaceSlash )
{
try
{
Query query = m_clConnection.query();

if ( replaceSlash )
{
//Backslashes doublen
replaceSubstring( &sql, "\\", "\\\\" );
}
//SQL statement an query weitergeben
query << sql.c_str();

//ausführen
ResNSel res = query.execute();

return res.insert_id;
}
catch (std::exception &er)
{
//skipped
return -1;
}
}

from time to time this works but if filecontent contains any sql chars
like " statement fails due syntax errors.
How do i tell query to ignore "filecontent" when syntax parsing is done ?



--
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: problems storing files in blobs - 01-14-2006 , 04:15 AM






Thomas Werth wrote:
Quote:
mysqlpp::escape_string( fill );
This does nothing.

Quote:
sql << mysqlpp::escape;
This also does nothing. You must use canonical stream syntax for the
escape manipulator to work:

sql << mysqlpp::escape << what_to_escape << ....

--
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.