Solved

How do I convert a Foxpro 2.6 database into MySQL ?

Posted on 2003-11-04
8
483 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 …

828 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