On Monday, September 29, 2003, at 03:29 PM, Carlos Vazquez wrote:

I want to create an application that transfers data from FoxPro (*.dbf)
tables to MySQL. Does MySQL have a DUMP like or LOAD LIKE function that
transfers this data in one step?


I just don't want to loop into thousands of records to insert them one
by one into my MySQL database.  It makes my program too slow and very
unlikely to use...

You can use the SQL PassThrough features of Visual FoxPro to do this quickly and easily. Create the table in MySQL with the same structure as your Fox DBF. Then run the following code in Fox:


lnHandle = SQLCONNECT( [your connection info] )
lcSQL = "select * from mytable where 0"
* This will create an empty cursor with the structure you need
SQLEXEC(lnHandle, lcSQL, "crsMyTable")
* Make the cursor updatable
MakeUpdatable("mytable", "crsMyTable", 5, "idfield")
SELECT crsMyTable
APPEND FROM MyFoxTable.DBF
? TABLEUPDATE(.T.)

If all goes well, the last line should print ".T." on the Fox screen.

"MakeUpdatable" is a handy utility written by Paul McNett that automatically does all the CURSORSETPROP calls for you. It is available for free on my website: http://leafe.com/dls/vfp



     ___/
    /
   __/
  /
 ____/
 Ed Leafe
 http://leafe.com/
 http://opentech.leafe.com


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to