[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

LOAD DATA LOCAL INFILE Vs Backslash

Posted on 2006-03-23
6
Medium Priority
?
1,440 Views
Last Modified: 2008-02-01
Hi

I'm using LOAD DATA LOCAL INFILE to import a comma separated file. However the file contains \(backslashes). Are there any way to get mysql not to escape thoses
0
Comment
Question by:sduItService
  • 3
  • 3
6 Comments
 
LVL 30

Expert Comment

by:todd_farmer
ID: 16270568
Hi sduItService,

LOAD DATA INFILE ... FIELDS ESCAPED BY '';  

Cheers!
0
 

Author Comment

by:sduItService
ID: 16275315
ERROR 1064 (42000): 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 'FIELD
S ESCAPED BY ''
0
 
LVL 30

Expert Comment

by:todd_farmer
ID: 16275403
What are you using as the actual command?  You will need to replace the ... with your existing parameters.  If you want to give me the full SQL command you were using initially, I can alter it for you.  I just don't know the other elements (file name, etc.) you are using.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:sduItService
ID: 16298113
use pcounter;
drop table log;
CREATE TABLE log (Username VARCHAR(15), Filename VARCHAR(100), Printer VARCHAR(50), Dato VARCHAR(15),tid VARCHAR(15), Workstation VARCHAR(20), spacer1 VARCHAR(20), spacer2 VARCHAR(20), Papertype VARCHAR(15), Parameters VARCHAR(50), Size VARCHAR(10), Pages VARCHAR(10), Cost VARCHAR(10), Balance VARCHAR(10));
LOAD DATA LOCAL INFILE 'C:\\temp\\pcounter.log'
INTO TABLE log
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
FIELDS ESCAPED BY ''
(Username, Filename, Printer, Dato, tid, Workstation, spacer1, spacer2, Papertype, Parameters, Size, Pages, Cost, Balance);
0
 
LVL 30

Accepted Solution

by:
todd_farmer earned 200 total points
ID: 16298198
Try this:

LOAD DATA LOCAL INFILE 'C:\\temp\\pcounter.log'
INTO TABLE log
FIELDS TERMINATED BY ','
ESCAPED BY ''
LINES TERMINATED BY '\n'
(Username, Filename, Printer, Dato, tid, Workstation, spacer1, spacer2, Papertype, Parameters, Size, Pages, Cost, Balance);

Also note that you don't have to drop and recreate the table unless you are changing the table format - you can replace the DROP and CREATE statements with the following:

TRUNCATE log;

0
 

Author Comment

by:sduItService
ID: 16298606
thx mate. It did the the job.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month18 days, 10 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question