Skip to Content.
Sympa Menu

freetds - [freetds] freebcp: add support for escaping characters?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: galt AT folkplanet.com
  • To: freetds list <freetds AT lists.ibiblio.org>
  • Subject: [freetds] freebcp: add support for escaping characters?
  • Date: 28 Mar 2006 12:49:31 -0800


First, I should say that freetds is wonderful!
I don't know what I'd do without it.

Currently I am transferring data from Sybase to MySQL.
It would be incredibly helpful if I could just have
each field (in -c char mode) escaped according to the mysql conventions.
Is there any hope of including support for this in freebcp?
We could either call the official mysql routine,
write our own without much effort if the dependency on mysql lib was not desired.

Here is an example:
char *sqlEscapeString(const char* from)
/* Prepares string for inclusion in a SQL statement . Remember to free
* returned string. Returned string contains strlen(length)*2+1 as many bytes
* as orig because in worst case every character has to be escaped.*/

char *sqlEscapeString2(char *to, const char* from)
/* Prepares a string for inclusion in a sql statement. Output string
* must be 2*strlen(from)+1 */
{
mysql_escape_string(to, from, strlen(from));
return to;
}

http://dev.mysql.com/doc/refman/5.0/en/mysql-real-escape-string.html

http://dev.mysql.com/doc/refman/5.0/en/string-syntax.html

I could just hack it in, but that would be distastefully
not fun to maintain. Do you think something like this would be accepted into the code base? If so I could make you a test version that does it.

Thanks for any help!









Archive powered by MHonArc 2.6.24.

Top of Page