Export to csv file from SQLite

I needed to get some data from SQLite database this week to import into MySQL, while doing that I thought this would make a good tip, just in case you don't know how this is done.

It's nice a simple, just follow these steps, once you have logged into your database.

  1. sqlite> .headers on
  2. sqlite> .mode csv
  3. sqlite> .output datafile.csv
  4. sqlite> select * from your_table;

Your query may change if you only want certain columns, or you may not want the headers, but as you can see you can easily change this to your suiting.

Then it will come back to your prompt.  When you exit out you will then be able to see your csv file.  You can then copy this to where ever you like and import it in.

I am always interested in feedback so please feel free to add any comments, or you can mail me  here.  If you would like to submit a quick tip  with full credit and links back to your site then also feel free to contact me.

Related Posts Plugin for WordPress, Blogger...



ERROR 13 (HY000): Can't get stat of

Ghost in the shell from the terminal