473,609 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysqldump to a csv

I am trying to create a CSV using mysqldump that will be viewed in MS Excel,
and have a formatting question.

From the command line I type:
mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=passwo rd > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.

I want to loose the table information, the "Insert into ..." text , and the
Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the
file.
Jul 19 '05 #1
8 17506

You could use the --xml switch and output to XML instead. If you need
CSV output from that, you could use an XSLT transform. If you have tons
of data, the transform could take awhile, but it would be a pretty easy
solution.

-John
Irvin Amoraal wrote:
I am trying to create a CSV using mysqldump that will be viewed in MS Excel,
and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=passwo rd > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.

I want to loose the table information, the "Insert into ..." text , and the
Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the
file.

Jul 19 '05 #2

You could use the --xml switch and output to XML instead. If you need
CSV output from that, you could use an XSLT transform. If you have tons
of data, the transform could take awhile, but it would be a pretty easy
solution.

-John
Irvin Amoraal wrote:
I am trying to create a CSV using mysqldump that will be viewed in MS Excel,
and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=passwo rd > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.

I want to loose the table information, the "Insert into ..." text , and the
Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the
file.

Jul 19 '05 #3
I believe it was Irvin Amoraal who said...
I am trying to create a CSV using mysqldump that will be viewed in MS Excel,
and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=passwo rd > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.

I want to loose the table information, the "Insert into ..." text , and the
Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the
file.


mysql -ppassword -e"select.... into outfile \"newfile.cs v\" fields
terminated by \",\""

I dont know if that'll be useful if there are commas in your data

--
-----------------------------------------------------------------------------
Chris van Ophuijsen RLU #195880
us****@gnubin.c om
put "HoboSong" in the subject
-----------------------------------------------------------------------------
Jul 19 '05 #4
I believe it was Irvin Amoraal who said...
I am trying to create a CSV using mysqldump that will be viewed in MS Excel,
and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=passwo rd > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.

I want to loose the table information, the "Insert into ..." text , and the
Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the
file.


mysql -ppassword -e"select.... into outfile \"newfile.cs v\" fields
terminated by \",\""

I dont know if that'll be useful if there are commas in your data

--
-----------------------------------------------------------------------------
Chris van Ophuijsen RLU #195880
us****@gnubin.c om
put "HoboSong" in the subject
-----------------------------------------------------------------------------
Jul 19 '05 #5
Chris,
I thought about and tried that. The "select ... into.." creates two files;
one with the table defenition, the other with the tabel data. I am concerned
about the commas.

When I tried it, it wrote the table defenition file, but not the data file.
I was unable to find out why.
Irvin Amoraal.
_______________ _______

"HoboSong" <us****@gnubin. com> wrote in message
news:um******** ***@192.168.1.7 5...
I believe it was Irvin Amoraal who said...
I am trying to create a CSV using mysqldump that will be viewed in MS Excel, and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename tablename --user=username --password=passwo rd > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.
I want to loose the table information, the "Insert into ..." text , and the Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the file.


mysql -ppassword -e"select.... into outfile \"newfile.cs v\" fields
terminated by \",\""

I dont know if that'll be useful if there are commas in your data

--
--------------------------------------------------------------------------

--- Chris van Ophuijsen RLU #195880
us****@gnubin.c om
put "HoboSong" in the subject
--------------------------------------------------------------------------

---
Jul 19 '05 #6
Chris,
I thought about and tried that. The "select ... into.." creates two files;
one with the table defenition, the other with the tabel data. I am concerned
about the commas.

When I tried it, it wrote the table defenition file, but not the data file.
I was unable to find out why.
Irvin Amoraal.
_______________ _______

"HoboSong" <us****@gnubin. com> wrote in message
news:um******** ***@192.168.1.7 5...
I believe it was Irvin Amoraal who said...
I am trying to create a CSV using mysqldump that will be viewed in MS Excel, and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename tablename --user=username --password=passwo rd > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.
I want to loose the table information, the "Insert into ..." text , and the Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the file.


mysql -ppassword -e"select.... into outfile \"newfile.cs v\" fields
terminated by \",\""

I dont know if that'll be useful if there are commas in your data

--
--------------------------------------------------------------------------

--- Chris van Ophuijsen RLU #195880
us****@gnubin.c om
put "HoboSong" in the subject
--------------------------------------------------------------------------

---
Jul 19 '05 #7
I'm not really keen on using XML at this time, as introduces another level
into the project I don't think I need. I will be creating the text file via
a PHP page, so if I can't do it using mysqldump, I could always do it
manually, getting the requisite data, then writing to a text file myself. I
just thought it might be easier to use mysql dump.

Irvin Amoraal.
_______________

"John" <no****@topleve l.tld> wrote in message
news:iy******** ********@newsre ad2.news.atl.ea rthlink.net...

You could use the --xml switch and output to XML instead. If you need
CSV output from that, you could use an XSLT transform. If you have tons
of data, the transform could take awhile, but it would be a pretty easy
solution.

-John
Irvin Amoraal wrote:
I am trying to create a CSV using mysqldump that will be viewed in MS Excel, and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=passwo rd > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.
I want to loose the table information, the "Insert into ..." text , and the Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the file.

Jul 19 '05 #8
I'm not really keen on using XML at this time, as introduces another level
into the project I don't think I need. I will be creating the text file via
a PHP page, so if I can't do it using mysqldump, I could always do it
manually, getting the requisite data, then writing to a text file myself. I
just thought it might be easier to use mysql dump.

Irvin Amoraal.
_______________

"John" <no****@topleve l.tld> wrote in message
news:iy******** ********@newsre ad2.news.atl.ea rthlink.net...

You could use the --xml switch and output to XML instead. If you need
CSV output from that, you could use an XSLT transform. If you have tons
of data, the transform could take awhile, but it would be a pretty easy
solution.

-John
Irvin Amoraal wrote:
I am trying to create a CSV using mysqldump that will be viewed in MS Excel, and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=passwo rd > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.
I want to loose the table information, the "Insert into ..." text , and the Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the file.

Jul 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2603
by: Mangina | last post by:
Hello all. Can anyone see why this snippet of code isnt dumping the databases using mysqldump ? All the credentials are correct (changed for the purpose of this post). $host = "localhost"; $user = "root"; $pass = "password"; $database = "database"; $dbname = array ("1","2","3","4","5");
0
493
by: Thiko | last post by:
Hi We currently use mysqldump to dump all our db's in quick mode to one file, backup.sql. This file has come quite large. mysqldump -Aq -u root > /MySQL/backup/backup.sql I would now like to split the mysqldump so that the output comprises of several files of less than 2 gigabytes each. Does anyone know the mysqldump options that could be used to do this? Or with using the >
7
7403
by: Adam Smith | last post by:
Hope this is the right news group!! I did a server upgrade and at the same time did a mysql update from 4.0.12 to Ver 12.22 Distrib 4.0.16 mach1# mysql --version mysql Ver 12.22 Distrib 4.0.16, for portbld-freebsd4.9 (i386) I attempted to restore the DB with
0
2259
by: mcstayinskool | last post by:
I'm trying to dump a bugzilla installation to a file, then restore it to a different database name (so as to test my db backup system). I use mysqldump to dump it to a file: # mysqldump -u root -p<passwd> (misc. options) bugs > bugs.sql Then try to restore it to an empty DB, "foobar" with this command # mysql -u root -p<passwd> foobar < bugs.sql It fails, with this not-too-helpful error:
1
4678
by: Greg.Harabedian | last post by:
I'll start off by saying I am using MySQL v4.0 and my question is...how do I get mysqldump to dump the actual binary values store in a blob? Here is an example: -- Create a test table create table dummy(col1 blob); -- Next insert a null ascii character (0) insert into dummy values (char(0)); -- To verify there is actually something there type: select length(col1) from dummy;
6
5964
by: Todd Cary | last post by:
My client is using a shared server running MySQL 2.4, however the in house server is 4.1.12 with mysqldump 10.9. Is there a way to have the 10.9 version output a format that is fully compatible with 2.4? Some of the CREATE TABLE statements in 10.9 are not accepted by 2.4. Currently, I am not using any of the switches in creating the output file other than the -u, -h and -p. Todd
6
30083
by: Robert Blackwell | last post by:
I want to make a scheduled task in windows to do a mysqldump. Someone gave me this .bat to run but I'm not able to get it to work. REM @echo off for /f "tokens=1" %%i in ('date /t') do set DATE_DOW=%%i for /f "tokens=2" %%i in ('date /t') do set DATE_DAY=%%i for /f %%i in ('echo %date_day:/=-%') do set DATE_DAY=%%i for /f %%i in ('time /t') do set DATE_TIME=%%i
6
6154
by: Antoni | last post by:
Hello, I'm trying to make a daily database backup. When executing "mysqldump - uxxx -pxxx database /home/backup/ddbb.sql -q &" the httpd server gets blocked and my site is "offline" for 30 minutes. I also tried using mysqlhotcopy, but with no success since it fails with error: "DBD::mysql::db do failed: Not unique table/alias: 'comments' at /usr/ bin/mysqlhotcopy line 466." I'd like to make a daily MySQL backup, but without freezing...
0
2921
by: Pratchaya | last post by:
How can i dump (mysqldump) with skip query logging ? Now, when i run mysqldump. mysql log ( query log ) default running/keeping all in result mysqldump. It's possible ? to run mysqldump without query logging ? ( when i run mysqldump .. i 'm not need to keey query log ) Thank you very much.
7
4712
by: damezumari | last post by:
I use Windows XP and Apache. I am trying to backup a database on my local computer with the following php code: $dbname = 'ol'; $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $backupFile = $dbname .'-' .date("Y-m-d-H-i-s") . '.sql';
0
8133
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8573
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8224
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8406
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7013
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4026
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2535
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1393
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.