List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:November 6 2002 4:26pm
Subject:Re: load data infile syntax
View as plain text  
At 11:18 -0500 11/6/02, Vivian Wang wrote:
>This is my statement using python,
>db.query("load data infile '/data/winshare/experian/test' into table 
>d_adds fields terminated by '' escaped by '\' lines terminated by 
>'\n'");
>Is python problem? not sure.

Looks like what's happening is that Python itself is processing escapes
before passing the query to MySQL, and MySQL itself will then process
escapes.  You have to account for the extra level of escape processing.
Try this:

db.query("load data infile '/data/winshare/experian/test' into table 
d_adds fields terminated by '' escaped by '\\\\' lines terminated by 
'\\n'");

>
>At 10:01 AM 11/6/2002 -0600, Paul DuBois wrote:
>>At 10:03 -0500 11/6/02, Vivian Wang wrote:
>>>I did my testing.
>>>If I use ESCAPED BY '\\', I got
>>>1064, "You have an error in your SQL syntax near ''' at line 2"
>>>
>>>Using ESCAPED BY '\', then no error and result is fine.
>>>If the data contains "\", then database will automatically takes 
>>>"\" away and shift 1 byte left.
>>>My data will mass up. That is why I still need "\"
>>>
>>>I posted my syntax before, but nobody helped me to figure out.
>>>So this time I did my test again and found out only need one "\" 
>>>for ESCAPED BY.
>>
>>I think there's something else wrong with the statement.  You do need
>>to use two backslashes to specify an escape character of a single backslash.
>>Can we see the entire LOAD DATA statement exactly as you specified it
>>originally?
>>
>>>At 10:43 PM 11/5/2002 -0600, you wrote:
>>>>At 14:38 -0500 11/5/02, Vivian Wang wrote:
>>>>>The syntac ESCAPED BY of load data infile is wrong in 
>>>>>http://www.mysql.com/doc/en/LOAD_DATA.html.
>>>>>
>>>>>the [ESCAPED by '\\']
>>>>>should be:
>>>>>[ESCAPED BY '\']
>>>>
>>>>Why do you say that?

Thread
load data infile syntaxVivian Wang5 Nov
  • Re: load data infile syntaxPaul DuBois6 Nov
    • Re: load data infile syntaxVivian Wang6 Nov
      • Re: load data infile syntaxPaul DuBois6 Nov
        • Re: load data infile syntaxVivian Wang6 Nov
          • Re: load data infile syntaxPaul DuBois6 Nov
            • Re: load data infile syntaxVivian Wang6 Nov
              • Re: load data infile syntaxPaul DuBois6 Nov
RE: load data infile syntaxAlan R Anderson7 Nov