user1179295
user1179295

Reputation: 746

whats the best way to parse a huge sql file

I am trying to parse a large sql file to a csv file. I have considered using fread in php but cant figure out if sql is separated by lines...bc I am assuming that fread is loading the data into RAM and that would not work.

Any ideas on how quickly convert sql to csv? (also I am running on a different machine than my db is on...so I cant export as csv unfortunately).

Upvotes: 1

Views: 1273

Answers (2)

goat
goat

Reputation: 31854

install mysql on your local machine. now you can import the sql file, then freely export as csv or whatever you want.

Upvotes: 0

Adi
Adi

Reputation: 49

"Large" - what does it mean to you. You can save to a file on server (the machine DB is running) and compress/download.

Exaple:

SELECT name,lastname,age FROM profile 

The query returns three columns of the mysql table. Now for redirecting/print into a file:

SELECT name,lastname,age FROM profile INTO OUTFILE '/tmp/userdata.txt' 

This will output data into the passed file in the above statement. To output data in terms of CSV format add more options to the query as following:

SELECT name,lastname,age FROM profile INTO OUTFILE '/tmp/userdata.txt'
    FIELDS enclosed by '"' separated by "," LINES TERMINATED BY '\n' 

original post

Upvotes: 1

Related Questions