Nils Guillermin
Nils Guillermin

Reputation: 1987

Getting datatypes from Paradox DB over ODBC into SQLite [Delphi]

I'm connecting to a .dbf using ODBC in Delphi using FireDAC. I've setup an ODBC connection, dBase 5.0, using the 32-bit Driver do Microsoft dBase (.dbf) driver.

In my IDE (Rad Studio 10.1 Berlin), I've setup the ODBC connection as a data source. The ODBCAdvanced connectiong string is DefaultDir=%s;DriverId=533;MaxBufferSize=2048;PageTimeout=5, where %s is the correct directory.

I managed to copy a table's structure to a SQLite db using TFields (code roughly as follows).

FieldNames := TStringList.Create;
PDOXTable.GetFieldNames(FieldNames);
FieldNames.Delimiter := ';';
FieldList := TList<TField>.Create;
PDOXTable.GetFieldList(FieldList, FieldNames.DelimitedText);

TempTable := TFDTable.Create(nil);
TempTable.Connection := TempConn;
TempTable.TableName := DataTable.TableName;
for I := 0 to FieldList.Count - 1 do TempTable.Fields.Add(FieldList.Items[I]);
TempTable.CreateTable(true, [tpTable, tpTriggers, tpIndexes]);

However, the data types are different and I don't have primary keys, notnull conditions, or 'dflt_value' which I got when I manually exported these same tables using an application called Exportizer (http://www.vlsoftware.net/exportizer/), which, though it has a command-line client, I'm not sure I'll be able to bundle with my application.

Comparing results of exporting to SQLite-from-Paradox-.dbf using Exportizer and code I wrote.

What is a reasonable way of copying a table from a paradox .dbf to a SQLite while saving as much of the datatypes and parameters as possible?

Upvotes: 1

Views: 803

Answers (1)

Victoria
Victoria

Reputation: 7912

Use TFDBatchMove. SQLite is typeless, but FireDAC has its own pseudo data type mapping with which you might be able to preserve a lot from original data types. And if the data types won't be exactly by your will, you can define your custom Mappings.

Upvotes: 0

Related Questions