| |||||||||||
mysql dump into a text file Posted by bschultz (bschultz), 17 September 2003 is there an easy way to dump a mysql db table into a text file, that is in a format suitable for reading? (for example - one column per line...etc)Posted by admin (Graham Ellis), 17 September 2003 You can select into outfile ...select * from course into outfile "/tmp/fred.txt"; This will give you a tab delimited file, one row per row of the table. Options are available to let you change the delimiter. I suggest you give a full absolute path, or the output file will be dumped (I think) in the MySQL user's home directory. If you want to transpose rows and columns, it's not straightforward - I read it that you want to do that, but perhaps I've misread the question? Posted by bschultz (bschultz), 18 September 2003 using the following code...that didn't work right. It put everything on the first "value", since it's tab delimited. Code:
I thought (obviously wrong!) that the Code:
would put each value on a new line. What am I doing wrong? Posted by admin (Graham Ellis), 19 September 2003 You're reading the whole file with your fread, so there's nothing left for your while loop and fgets. Have a look at the MySQL docs for the "into outfile" stuff too - there's options you can use to change separators and things ike that whihc might format the data better for your particular requirement.Posted by bschultz (bschultz), 19 September 2003 thanks, Graham. I was looking (without any luck) at the php.net docs.Brian This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |