Solved

How do I convert a Foxpro 2.6 database into MySQL ?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 98
mapBully challenge 6 113
Installed softare without GUID 6 65
Please help| Getting the syntax error in below query. 2 42
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 fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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…

932 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now