Solved

How do I convert a Foxpro 2.6 database into MySQL ?

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
This article will show, step by step, how to integrate R code into a R Sweave document
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

707 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

16 Experts available now in Live!

Get 1:1 Help Now