Notifications
Clear all

Parsing SQL

9 Posts
6 Users
0 Reactions
1,201 Views
(@chrism)
Trusted Member
Joined: 16 years ago
Posts: 97
Topic starter  

I've got a SQL file that needs to be parsed into something readable, like a CSV file or an excel spreadsheet.

Any one know of any tools that could do this? The SQL file is a dump from phpMyAdmin. I would like to avoid installing phpMyAdmin on a local machine if there is some software out there can could do this for me.


   
Quote
 ddow
(@ddow)
Reputable Member
Joined: 21 years ago
Posts: 278
 

Is it Pipe delimited? Not exactally sure what you have with a "SQL File" but most database export functions will delimite the fields of the table with some character with the pipe (|) being most common. Most spread sheet programs can read these and use the symbol as the delimiter.


   
ReplyQuote
(@Anonymous 6593)
Guest
Joined: 17 years ago
Posts: 1158
 

I've got a SQL file that needs to be parsed into something readable, like a CSV file or an excel spreadsheet.

Is it a 'recreate database script' kind of thing, with some CREATE TABLE at the top and a lot of INSERTs into those tables?

The simplest thing is probably to execute it, and let it do its stuff. You'll need to know abit about SQL types and perhaps dialects to decide what kind of database environment will accept those types. If you know the database it's for, use that if you can.


   
ReplyQuote
(@Anonymous)
Guest
Joined: 1 second ago
Posts: 0
 

I've got a SQL file that needs to be parsed into something readable, like a CSV file or an excel spreadsheet.

Any one know of any tools that could do this? The SQL file is a dump from phpMyAdmin. I would like to avoid installing phpMyAdmin on a local machine if there is some software out there can could do this for me.

Mayhew, I suggest that you post the first 15-20 lines of this file so that we can better determine its type. We do not understand what you mean by the phrase, "a dump from phpMyAdmin." MySQL has an utility called "mysqlDump." Did PHPmyAdmin (a web application) use that utility to dump a MySQL database?

If it is a mysqlDump file, then re-loading it into a MySQL server and creating a new database is usually an easy task. You would not need to install any of the following software packages PHPmyAdmin, Apache, mod_php, PHP, etc.


   
ReplyQuote
(@jdcoulthard)
Trusted Member
Joined: 16 years ago
Posts: 98
 

If you download the SQLite Browser from Sourceforge it allows you to export a table directly to CSV.

Hope this helps D


   
ReplyQuote
jhup
 jhup
(@jhup)
Noble Member
Joined: 16 years ago
Posts: 1442
 

Is it a .sql file with all the drops, creates inserts?

As paulbain suggests, lot of hosted web site control panels export the MySQL DBs in such format.

You can run it in Access, and all the creates and inserts will be executed.

From there you would be able to manage it accordingly.


   
ReplyQuote
(@jdcoulthard)
Trusted Member
Joined: 16 years ago
Posts: 98
 

Sorry I really should read things properly before posting 😉

When I have needed to do anything with MySQL dumps in the past I have usually installed MySQL on a VM and then used standard query browsers to get the data out.

XAMP is a nice all in one solution that will configure MySQL for you.


   
ReplyQuote
(@chrism)
Trusted Member
Joined: 16 years ago
Posts: 97
Topic starter  

We do not understand what you mean by the phrase, "a dump from phpMyAdmin." MySQL has an utility called "mysqlDump." Did PHPmyAdmin (a web application) use that utility to dump a MySQL database?

Yes the file has phpMyAdmin written at the start of the file, so I assume the suspect made a backup straight from phpMyAdmin, or got his hosting company to send him a backup.

If it is a mysqlDump file, then re-loading it into a MySQL server and creating a new database is usually an easy task.

After trying for what seems like hours to get MySQL to talk to PHP/Apache I just used the mysql program via command prompt to import the SQL dump (it did have all the drops, creates etc) into a new database and from there I used the command

mysql> select * from TABLE into outfile 'example.text';
Then imported the file into Excel and now I can easily give this to the client. Thanks for all the replies.

It's stupid how some things are just that simple after trying all the complicated methods!


   
ReplyQuote
jhup
 jhup
(@jhup)
Noble Member
Joined: 16 years ago
Posts: 1442
 

MySQL has a local client version "Workbench", which works well for me.


   
ReplyQuote
Share: