Skip to Content.
Sympa Menu

freetds - Re: [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 Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] freebcp: add support for escaping characters?
  • Date: 28 Mar 2006 15:50:38 -0800


Also, if freebcp could simply check to see if the terminator
is contained in the field it is about to write, it could treat that as an error and tell the user about it as soon as it happened.

Otherwise, it slips right through and screws things up much further down the pipeline making recovery painful.
-Galt

On Mar 28 2006, Lowden, James K wrote:

> From: galt AT folkplanet.com
> Sent: Tuesday, March 28, 2006 3:50 PM
> > First, I should say that freetds is wonderful! I don't know what
> I'd do without it.

Good to hear. :-)

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

Before we do that, wouldn't this bit 'o Perl almost do what you want?
#! /usr/bin/perl -p
$end = chop;
s:['"\\_%]:\\$&:g; # literal escapes
s:\x0:\\0:g; # NUL
s:\b:\\b:g; # backspace
s:\n:\\n:g; # newline
s:\r:\\r:g; # return
s:\t:\\t:g; # tab
s:\cZ:\\z:g; # ^Z
print $_, $end;

It wouldn't be easy to add to freebcp. You'd wind up adding it to
src/dblib/bcp.c I think, because that's where the convert-to-character
and write-to-file functions are. You'd have to pass the "do the MySQL
thing" flag pretty deep into the code.
It's also icky. The whole idea of escaping my data so the utility I'm
using doesn't get confused about quoting and ^Z is pretty lame, if you
ask me. It should be the other way around: presented with clearly
described data, the utility should convert it to its internal format and
do its thing. From my perspective, everything but the delimiter is a
literal value. Isn't that the usual way?
Does MySQL have anything that helps you load something more standard,
like, say, CSV files? I could see adding CSV as a format that freebcp
understands.
--jkl



----------------------------------------- The information contained in this transmission may be privileged and confidential and is intended only for the use of the person(s) named above. If you are not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender immediately by reply e-mail and destroy all copies of the original message. Please note that we do not accept account orders and/or instructions by e-mail, and therefore will not be responsible for carrying out such orders and/or instructions. If you, as the intended recipient of this message, the purpose of which is to inform and update our clients, prospects and consultants of developments relating to our services and products, would not like to receive further e-mail correspondence from the sender, please "reply" to the sender indicating your wishes. In the U.S.: 1345 Avenue of the Americas, New York, NY 10105. _______________________________________________ FreeTDS mailing list FreeTDS AT lists.ibiblio.org http://lists.ibiblio.org/mailman/listinfo/freetds





Archive powered by MHonArc 2.6.24.

Top of Page