Solved

VFP9 & Remote MySQL Backup to Local

Posted on 2010-11-27
4
511 Views
Last Modified: 2012-05-10
Hi all. I have an FP application that makes use of a MySQL db that resides on a remote server.

Locally, I have MySQL installed on Windows and from time to time I use a third-party program to copy all the MySQL tables from the remote server to my local windows installation. This works well but has several manual steps and cannot be run unattended.

What I would like to do is accomplish the same thing, but within my FP app. But I'm not sure where to begin.

Since I can run queries on the remote MySQL db and the local MySQL db, I'm assuming there must be a way to determine what tables exist along with their structure, and recreate those tables locally. And I guess the data as well?

Like I said I'm unsure where to begin, so your help would be greatly appreciated.




0
Comment
Question by:formadmirer
4 Comments
 
LVL 41

Accepted Solution

by:
pcelba earned 350 total points
ID: 34222278
If you are able to connect to the MySQL server via SQLCONNECT() or SQLSTRINGCONNECT() then you may simply obtain a list of all MySQL tables:

SQLTABLES(lnSqlHandle, "TABLE", "cTables")

Columns for certain table are also easy to populate:

SQLCOLUMNS(lnSqlHandle, "TableName", "NATIVE", "cColumns")

Some code examples are e.g. here:
http://msdn.microsoft.com/en-us/library/f3c5e4wf(VS.80).aspx
http://msdn.microsoft.com/en-us/library/wfktfyx0(VS.80).aspx


More ways of MySQL data handling from VFP are described in the following book which I highly recommend:
http://www.hentzenwerke.com/catalog/mysqlvfp.htm
0
 
LVL 29

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 150 total points
ID: 34222285
How about using a tool like MySQL dump?

http://dev.mysql.com/doc/refman/4.1/en/mysqldump.html

Otherwise, your plan could be done, there is SHOW TABLES to list all tables and SHOW CREATE TABLE will give a create a CREATE TABLE statement you'd need to create a table locally as it's defined remotely.

Nevertheless perhaps first have a read of mysqldump before reinventing the wheel.

Also, if you actually need database replication to have your local database up to date all the time instead of copying the database from time to time, then have a read on replication here: http://dev.mysql.com/doc/refman/5.0/en/replication.html

Bye, Olaf.
0
 

Author Comment

by:formadmirer
ID: 34222504
Thx for the info. I plan to work some with the suggestions from both later on today and see how it goes.

And thanks for the book link. I had no idea a book existed specifically for using MySQL with VFP. I'm currently looking for the best price online and definitely plan on getting this.
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34223102
Virtually anything can be automated unless it does not involved a human decision. If a user is clicking or typing it can be automated. If he is thinking, it might be automated. :-)
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
visual foxpro spellchk.app doesn't work 30 77
window php adodb connect to remote foxpro db folder 3 1,384
FWRITE() function giving odd results 7 96
DBF to ... Converter 5 69
Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Read about the ways of improving workplace communication.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question