Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading Paradox Database files

I'm working with a client who has an existing system, built on what is apparently a Paradox database. I've got the database, in the form of a zip file containing .DB, .MB and .PX files, one for each table.

I need to take (some) of this data and import it in to a Web application that's using MySQL. Does anybody have a way for me to extract this data, that doesn't involve installing Paradox?

If not, does Paradox export in some readable format? Either as SQL or something that can be parsed reasonably easily? The person in charge of this system for my client is a volunteer (they're a non-profit), so I'd like to go to him with a solution - because last time I asked for the data, I got this, which is clearly no good.

like image 321
MattBelanger Avatar asked Oct 24 '09 04:10

MattBelanger


2 Answers

The wikipedia article about Paradox lists two other things, that might be interessant, both under GPL license:

  • pxlib: Library to read and write Paradox databases
  • pxtools: convert a Paradox-database into a SQL-database

And if you have Delphi and want to write a converter yourself (which would need the BDE to work) you can take a look at this article or at the source code of ConvertCodeLib on this web site. Both make use of TClientDataset, which can write a CDS (binary format) or an XML file.

like image 62
Name Avatar answered Sep 28 '22 06:09

Name


I've been working on a gigantic data migration from Paradox to MySQL. My general approach has been to export CSV files from Paradox, and then import the CSV files from the MySQL command line. However this system breaks down when there are M (memo) fields in Paradox, because that data doesn't get pulled into the CSV file as expected.

Here's my long-winded process for getting Paradox data into MySQL, hopefully it helps somebody!

  • Open Paradox file in Paradox, export to dbase (.dbf) file. What this does is it exports the memo data into dbase's blob format.

  • Open the .dbf file in Paradox. It might be necessary to convert double format to long integer or number before opening in dbfviewer. Double format appears to not be working. Save file.

  • Use this program to open up the dbase file and then export to Excel: http://dbfviewer.org/ Export -> XLS-File … this opens it in Excel

  • Now we need to create a macro because Excel doesn't have any native way to enclose CSV fields with quotes or anything else. I've pasted the macro below, but here are the reference sites that I found. One site had better instructions but corrupted text: http://www.mrexcel.com/forum/showthread.php?320531-export-as-csv-file-enclosed-quotes http://www.markinns.com/articles/full/export_excel_csvs_with_double_quotes/

  • In Excel replace all " with ' by CTRL-F, replace... any " in records will mess stuff up

  • In Excel press ALT - F11 to open up macros Insert -> Module Create this macro to save CSV files enclosed with double quotes:

    Sub CSVFile()

    Dim SrcRg As Range
    Dim CurrRow As Range
    Dim CurrCell As Range
    Dim CurrTextStr As String
    Dim ListSep As String
    Dim FName As Variant
    FName = Application.GetSaveAsFilename("", "CSV File (*.csv), *.csv")
    
    If FName <> False Then
    ListSep = Application.International(xlListSeparator)
    If Selection.Cells.Count > 1 Then
    Set SrcRg = Selection
    Else
    Set SrcRg = ActiveSheet.UsedRange
    End If
    Open FName For Output As #1
    For Each CurrRow In SrcRg.Rows
    CurrTextStr = ""
    For Each CurrCell In CurrRow.Cells
    CurrTextStr = CurrTextStr & """" & CurrCell.Value & """" & ListSep
    Next
    While Right(CurrTextStr, 1) = ListSep
    CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)
    Wend
    Print #1, CurrTextStr
    Next
    Close #1
    End If
    End Sub
    
  • Then Run -> Run Macro

  • Set up target MySQL db schema with text fields where we want the blobs to go

  • In MySQL command line here's an example of how to do the import:

    LOAD DATA LOCAL INFILE 'C:/data.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' (column1, column2)

like image 34
Scott Hildebrand Avatar answered Sep 28 '22 04:09

Scott Hildebrand