homepage Welcome to WebmasterWorld Guest from 54.161.240.10
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
Going nuts with load data infile
mysql, load data infile
belfasttim




msg:4039680
 9:27 pm on Dec 8, 2009 (gmt 0)

Hi-- I'm having a persistent problems with a mysql LOAD DATA INFILE job I'm running. I have three or four csv files I need to import into a db, they all fail with the same error. I've googled all over and tried a bunch of things to fix it, but can't figure out why this is popping up. Thanks in advance for any help! (Note: using the exact same files and options worked fine with a mysqlimport, but it fails using load data infile which I thought was basically identical!)

here's the statement:


LOAD DATA LOCAL INFILE '/scripts/myfile.txt' INTO TABLE table (id,title) FIELDS TERMINATED BY ',' ENCLOSED BY '"'

Here's a sample of the actual txt file:
"A01","Handicap features"

The database table is simply two columns: id varchar(5) and title varchar (255)

I've tried the statement both with and without the LOCAL modifier, it seems to make no difference. The error I get is

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FIELDS TERMINATED BY ',' ENCLOSED BY '"'' at line 1

As far as I can tell from reading the manual and about a dozen examples is that my syntax is correct. Any ideas?

Thanks

 

belfasttim




msg:4039797
 1:26 am on Dec 9, 2009 (gmt 0)

SOLVED: for anyone finding this, there's quite a few incomplete or erroneous examples on the net. Here's the right syntax:

LOAD DATA LOCAL INFILE '/scripts/myfile.txt' INTO TABLE table FIELDS TERMINATED BY ',' ENCLOSED BY '"' (id,title)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved