Jump to content

Mysqldump Table Issue


jazzman1

Recommended Posts

Hey friends,

Let's say that I have a database named - "test".

Inside this database, I have a table, it's called - 'product'.

If I try to get an information from the product table produsing as html output, I'm using the code below.

 

Example:

 

[jazzman@localhost ~]$ mysql -h localhost -u jazzman --password='password' --html

mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed

mysql> SELECT * FROM product;
<TABLE BORDER=1><TR><TH>id</TH><TH>name</TH><TH>purchase_id</TH></TR><TR><TD>1</TD><TD>Lawn Mower</TD><TD>1</TD></TR><TR><TD>2</TD><TD>Greenhouse</TD><TD>1</TD></TR><TR><TD>3</TD><TD>Paving slab</TD><TD>2</TD></TR><TR><TD>4</TD><TD>BBQ</TD><TD>2</TD></TR><TR><TD>5</TD><TD>Chainsaw</TD><TD>5</TD></TR><TR><TD>6</TD><TD>Power-MP3 5gb</TD><TD>2</TD></TR><TR><TD>7</TD><TD>Super-Player 1gb</TD><TD>3</TD></TR><TR><TD>8</TD><TD>Porta CD</TD><TD>3</TD></TR><TR><TD>9</TD><TD>36" TV</TD><TD>1</TD></TR><TR><TD>10</TD><TD>Family Talk 360</TD><TD>5</TD></TR></TABLE>10 rows in set (0.00 sec)

 

 

What I want to do is, runing a mysqldump to get only this particular html output.

 

What do you think, is it possible?

 

Thanks in advance.

Edited by jazzman1
Link to comment
Share on other sites

I don't think you can apply formating to a mysqldump, that said - I have never thought to try. It's not supposed to produce a nice shiny report, it's ment as a backup tool.

 

@muddy, I've never thought to try, too ;)

Actually, this is a question from one bulgarian forum.

The guy of that forum doesn't have a web server neither any knowledges of server side languages. He knows only html and a little sql.

His question was, is it a way to generate database tables as html document(s) in my browser?

I've suggested him to use a mysqldump tool dumping tables as xml document, after that just using javascript to retrieve this data, but he doesn't have any experience in javascript, too.

Well, that's the story :)

 

Anyway, I wrote a simple bash script which get the data from db tables saving it in html document. It works properly.

Example:

 

#!/bin/sh
CMD="use test;select * from product"
/usr/bin/mysql -h 127.0.0.1 -u jazzman --password="password" --html -e "$CMD" > /home/jazzman/index.html

 

Have a good one.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.