Solved

How do I convert a Foxpro 2.6 database into MySQL ?

Posted on 2003-11-04
8
480 Views
Last Modified: 2006-11-17
How do I convert a Foxpro 2.6 database into MySQL ?
asim
0
Comment
Question by:masimiqbal
  • 3
  • 2
8 Comments
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9676976
download the mysql odbc diver and create an dsn

create a link table in access for the the foxpro database then right click select export choose the odbc database and select your dsn Thats it you are done!
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9677504
can you please close 2 other questions? write to the community support to close them.
if you want to convert foxpro programtically generate the sql statements and fire them
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9684205
masimiqbal:you can download mysql odbc driver from mysql's site
0
 
LVL 3

Accepted Solution

by:
steve918 earned 125 total points
ID: 9731469
* Heres a program I wrote to do just that.
* 1. Copy this text to foxtosql.prg
* 2. In foxpro run: Do foxtosql "database.dbf", "outfile.sql"
* 3. Now Run: mysql -uuser -ppass database<outfile.sql
*
* Note:  You must first create the database in mysql this program does not
* produce the table structure.  You could easily tweak it to produce the table
* structure, but I prefer to build the table the way I want it in mysql instead
* having the program guess at data types and such.
 
PARAMETERS pDBF,pOutfile

Private xi
Private xCOLARRY


Set TEXTMERGE ON
SET TEXTMERGE TO &pOutFile

If !USED(pDbf)
      SELECT 0
      Use &pDBF
EndIf

=Afields(xCOLARRY)

Scan

      \INSERT INTO todo VALUES ('

      For xi = 1 to int(alen(xCOLARRY)/4)
            
            Do Case
                  Case Inlist(xCOLARRY(xi,2),"C","M")      
                        xStr = &xCOLARRY(xi,1)
                        \\<<Alltrim(_SpecChars(xStr))>>
                        xStr = ""
                  Case Inlist(xCOLARRY(xi,2),"F","N")
                        xNum = &xCOLARRY(xi,1)
                        \\<<Alltrim(Str(xNum))>>
                        xNum = 0
                  Case xCOLARRY(xi,2) = "D"
                        xDate = &xColArry(xi,1)
                        \\<<Alltrim(_FmtDate(xDate))>>
                        xDate = {}
            EndCase
      
            If !(xi=int(alen(xCOLARRY)/4))      
                  \\','
            EndIf

      EndFor

      \\');

EndScan

flush
close all

*
*
*
Function _FmtDate
Parameters pDate

Private xDate
Private xMon
Private xYear
Private xDay

If Empty(pDate)
      Return( "0000-00-00" )
EndIf

pDate = dtos(pDate)
xYear = Left(pDate,4)
xMon = Substr(pDate,5,2)
xDay = Right(pDate,2)

xDate = xYear + "-" + xMon + "-" + xDay
Return( xDate )


*
*
*
Function _SpecChars
      Parameters xTodo

      xTodo = Strtran(xTodo,"\","\\")
      xTodo = Strtran(xTodo,chr(13),"\r")
      xTodo = Strtran(xTodo,chr(10),"\n")
      xTodo = Strtran(xTodo,chr(09),"    ")
      xTodo = Strtran(xTodo,'"','\"')
      xTodo = Strtran(xTodo,"'","\'")


      Return(xTodo)
0
 
LVL 3

Expert Comment

by:steve918
ID: 9731484
LOL, I just realize the _SpecChars function uses xTodo as a parameter, I built this program to convert a "TODO" database from foxpro to MySQL
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

A short article about a problem I had getting the GPS LocationListener working.
This is an explanation of a simple data model to help parse a JSON feed
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

770 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