[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 12-18-2006, 01:45 PM   #1 (permalink)
DomainersUniversity.com

Team Leader

 
Gene's Avatar
 
Join Date: Feb 2005
Location: Oswego, NY
Posts: 4,718
96.11 NP$ (Donate)

Gene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond repute

Ethan Allen Fund Cancer Survivorship Baby Health Cystic Fibrosis Marrow Donor Program Parkinson's Disease Child Abuse
MySQL: Automatically download tables

I have a MySQL database containing many tables. Two of those tables need to be downloaded on a daily basis at 9am. How can I go about automating this process? I simply need to download the two tables in CSV format to a directory on the server. Does this require a 'cron job'? Or is there a procedure that is stored in the database somehow? Thanks in advance for any advice!
__________________
.
.

Gene is offline  
Old 12-18-2006, 01:49 PM   #2 (permalink)
A Wealth of Knowledge
 
stscac's Avatar
 
Join Date: Aug 2004
Posts: 3,794
47.60 NP$ (Donate)

stscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud of


Looking for a server based solution or a paid desktop solution?

A quick google search shows http://www.swordsky.com/

A server-based one is http://www.dagondesign.com/articles/...backup-script/

I'm sure someone can modify it to fit your needs.

-Steve
__________________
Follow Me on Twitter:
stscac is offline  
Old 12-18-2006, 02:05 PM   #3 (permalink)
DomainersUniversity.com

Team Leader

 
Gene's Avatar
 
Join Date: Feb 2005
Location: Oswego, NY
Posts: 4,718
96.11 NP$ (Donate)

Gene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond repute

Ethan Allen Fund Cancer Survivorship Baby Health Cystic Fibrosis Marrow Donor Program Parkinson's Disease Child Abuse
Thanks Steve, Server-based is likely what I need, but I don't know enough about this to know what to look for. Is specialized software really necessary? I thought a simple command line somewhere would achieve the goal of downloading the CSV files.
__________________
.
.

Gene is offline  
Old 12-18-2006, 02:47 PM   #4 (permalink)
A Wealth of Knowledge
 
stscac's Avatar
 
Join Date: Aug 2004
Posts: 3,794
47.60 NP$ (Donate)

stscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud of


Quote:
Originally Posted by Gene
Thanks Steve, Server-based is likely what I need, but I don't know enough about this to know what to look for. Is specialized software really necessary? I thought a simple command line somewhere would achieve the goal of downloading the CSV files.
Its a mixture of a crontab, a mysql query to extract the database, and then use php (or language of choice) to put it on the server.

I'll see what I can come up with.

Edit: Looks like this might be what you're looking for. With a little modification, it can be added to the server.



-Steve
__________________
Follow Me on Twitter:

Last edited by stscac; 12-18-2006 at 02:54 PM.
stscac is offline  
Old 12-18-2006, 03:04 PM   #5 (permalink)
DomainersUniversity.com

Team Leader

 
Gene's Avatar
 
Join Date: Feb 2005
Location: Oswego, NY
Posts: 4,718
96.11 NP$ (Donate)

Gene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond repute

Ethan Allen Fund Cancer Survivorship Baby Health Cystic Fibrosis Marrow Donor Program Parkinson's Disease Child Abuse
Thanks for finding that, but I don't think it will do what I need. I need to download two of the 'tables' that reside in one of my databases, and save these two tables as a CSV file to a folder on the server on a daily basis. No other database files should be included. Just two CSV files. No backup rotation. The same files should be overwritten every day.
__________________
.
.

Gene is offline  
Old 12-18-2006, 03:21 PM   #6 (permalink)
A Wealth of Knowledge
 
stscac's Avatar
 
Join Date: Aug 2004
Posts: 3,794
47.60 NP$ (Donate)

stscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud of


Quote:
Originally Posted by Gene
Thanks for finding that, but I don't think it will do what I need. I need to download two of the 'tables' that reside in one of my databases, and save these two tables as a CSV file to a folder on the server on a daily basis. No other database files should be included. Just two CSV files. No backup rotation. The same files should be overwritten every day.
If you can't find your fit, PM me and I can try to come up with a custom solution.

-Steve
__________________
Follow Me on Twitter:
stscac is offline  
Old 12-19-2006, 02:29 AM   #7 (permalink)
Domains my Dominion
 
sdsinc's Avatar
 
Join Date: Aug 2005
Location: Web 1.0
Posts: 6,285
1,095.94 NP$ (Donate)

sdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond repute

Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer
Quote:
Originally Posted by Gene
I have a MySQL database containing many tables. Two of those tables need to be downloaded on a daily basis at 9am. How can I go about automating this process? I simply need to download the two tables in CSV format to a directory on the server. Does this require a 'cron job'? Or is there a procedure that is stored in the database somehow? Thanks in advance for any advice!
For bulk import/export in mySQL you have LOAD DATA INFILE (import) and SELECT INTO (export).

Step 1: prepare your SQL statement with the fields you want exported.
Example:
Code:
USE your_database; # select DB

SELECT field1, field2 INTO OUTFILE '/destination/result.txt'
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
  LINES TERMINATED BY '\n'
  FROM your_table;
Step 2:
When you are OK with the SQL put the code into a file and save it somewhere on your server

Step 3:
Test the script from the command line (login via telnet/SSH):

/usr/local/mysql -uroot -ppassword < /scripts/mysqlcsv

In this example I assume your DB user name is root and password is password (highlighed).
I also assume that the file containing the SQL statement is saved as /scripts/mysqlcsv. The command above will instruct mySQL to process the instructions in the file.
Please note that the mySQL path may differ on your server. Use the following shell command to determine the mysql path if needed:

whereis mysql

Step 4:
When your script is working from command line as per above then you just add a cronjob entry with that command line. And the job is now automated.

Shoot me a PM if you require further assistance.
__________________
Buy now - MassDeveloper.com $500
sdsinc is online now  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 04:01 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85