PGDBF(1)
π PGDBF π
okay bestie, so pgdbf is a little command from the General Commands Manual, section 1 (iykyk, that's "user commands"), and it's genuinely iconic: it converts XBase / FoxPro tables into PostgreSQL. she's small, she's fast, she's that girl.
β¨ SYNOPSIS β¨
pgdbf [-cCdDeEhqQtTuU] [-m memofile] filename [indexcolumn ...]
πΈ DESCRIPTION πΈ
So PgDBF is a program for converting XBase databases β especially FoxPro tables with memo files β into a format that PostgreSQL can directly import. It's a compact C project with no dependencies other than standard Unix libraries. Like, none. she's self-sufficient, she's low-maintenance, she's thriving. π«Ά
Even though the project is relatively tiny and simple, it's also heavily optimized via profiling β routine benchmarks were many times faster than with other Open Source programs. Not me being dramatic, it's literally in the docs. And on slower systems, conversions are typically limited by hard drive speed. the disk is the bottleneck, not her. π
π Features
PgDBF was designed with a few core principles, and honestly? the vision was clear:
- Simplicity. This code should be understandable by anyone who wants to hack it. open invitation, bestie.
- Robustness. Every syscall that might possibly fail is checked for success. every single one. she does not skip the vibe check.
- Speed. PgDBF was born to be the fastest conversion available anywhere. main character energy fr.
- Completeness. It has full support for FoxPro memo files.
- Portability. PgDBF runs on 32- and 64-bit systems, and both little-endian (eg x86) and big-endian (eg PowerPC) architectures. she gets along with everyone. π
β‘ Performance
PgDBF's speed is generally limited by how fast it can read your hard drives. A striped RAID of quick disks can keep PgDBF pretty well fed on a single-processor system. One problem area is with memo files, which may become very internally fragmented as memo fields are created, deleted, and updated. For best results, consider placing the DBF and FPT files on a RAM drive so that there's no seek penalty as there is with spinning hard drives, or using a filesystem such as ZFS that caches aggressively. π§ β¨
One particularly fragmented 160MB table with memo fields used to take over three minutes on a FreeBSD UFS2 filesystem. Moving the files to a RAM disk dropped the conversion time to around 1.2 seconds. the glow-up was astronomical.
A certain test table used during development comprises a 280MB DBF file and a 660MB memo file. PgDBF converts this to a 1.3 million row PostgreSQL table in about 11 seconds, or at a rate of almost 120,000 rows per second. she ate and left no crumbs. π₯
π OPTIONS π
-cβ Generate aCREATE TABLEstatement to make a table with similar datatypes and column names as the DBF file. Default.-Cβ Suppress theCREATE TABLEstatement. (not her, she's still here)-dβ Generate aDROP TABLEstatement before theCREATE TABLEstatement. This is useful for replacing the contents of a table that already exists in PostgreSQL. Default.-Dβ Suppress theDROP TABLEstatement.-eβ Change theDROP TABLEstatement toDROP TABLE IF EXISTSso that newer versions of PostgreSQL (8.2+) will only attempt to drop the table if it's already defined. PostgreSQL will return an error when attempting to drop a table that does not exist unlessIF EXISTSis used. Default.-Eβ Do not use theIF EXISTSmodifier toDROP TABLE, for compatibility with versions of PostgreSQL older than 8.2.-hβ Print a help message, then exit. bye bestie π-mmemofile β The name of the associated memo file (if necessary).-nβ CreateNUMERICfields with typeNUMERIC. Default.-Nβ CreateNUMERICfields with typeTEXT. Use this if rows contain invalid number data inNUMERICfields (which are essentiallyCHARACTERfields behind the scenes). lowkey a lifesaver when your data is messy.-pβ Show a progress bar during the conversion process. we love watching the little bar fill up π₯Ή-Pβ Do not show a progress bar. Default.-qβ Enclose the name of the table in quotation marks in statements like"CREATE TABLE","DROP TABLE", and so on. This is useful in cases where the table name is a PostgreSQL reserved word, and almost certainly harmless in all other cases.-Qβ Do not enclose the name of the table in quotation marks. Default.-sencoding β Set the encoding used in the input file. When given, output will be converted from that encoding toUTF-8. Supported encodings depend on your version of the iconv library. Available only if your copy of PgDBF was compiled with iconv support. π check before you assume.-tβ Wrap the entire script in a transaction. Default.-Tβ Remove the wrapper transaction. This is generally not a good idea as it can cause the table to appear completely empty to other clients during the data copying phase. If the entire process occurs inside a transaction, the update is atomic and other clients will have full access to all data in the table at all times. > β οΈ bestie, this one's a trap. she said what she said.-uβ Issue aTRUNCATE TABLEstatement to clear the contents of a table before copying data into it.-Uβ Suppress theTRUNCATE TABLEstatement. Default.
π OPTION NOTES π
The -c and -d arguments are incompatible with -u, as it's pointless to truncate a newly-created table. Specifying -c or -d will disable the TRUNCATE TABLE statement as though -U was given. Similarly, using the -u argument will disable the CREATE TABLE and DROP TABLE statements as if -C and -D were given. they simply will not coexist, periodt.
π BUGS π
When multiple incompatible interpretations of a type are available, such as the B type which can mean binary object in dBASE V or double-precision float in FoxPro, PgDBF currently uses the FoxPro interpretation. so if you're a dBASE V personβ¦ yeah. π
Most XBase datatypes are supported, but some are not (yet). As of this writing, PgDBF can handle boolean, currency, date, double-precision float, float, general (although only outputs empty strings; it's unclear how to resolve OLE objects at this time), integer, memo, numeric, timestamp, and varchar fields. If you need other datatypes, send a small sample database for testing. π (fr fr, they want your test files)
π AUTHOR π
Kirk Strauser <kirk@strauser.com>
and that's the whole page, bestie β Version 0.6.2, dated September 30 2012, straight from the PgDBF source distribution. go forth and convert your tables, she's rooting for you. π¦πβ¨
π¦ where this page comes from
- debian bookworm: pgdbf 0.6.2-1.1+b2
- debian trixie: pgdbf 0.6.3+git20180121.4e84775-1 Β· GPL-3.0-or-later
- ubuntu jammy: pgdbf 0.6.2-1.1build1
- ubuntu noble: pgdbf 0.6.2-1.1build1
- ubuntu questing: pgdbf 0.6.3+git20180121.4e84775-1
- ubuntu resolute: pgdbf 0.6.3+git20180121.4e84775-1build1 Β· GPL-3.0-or-later
- ubuntu stonking: pgdbf 0.6.3+git20180121.4e84775-2 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms