A Python package for reading and writing DBF files, powered by a Rust core
Project description
fastdbf
fastdbf is a high-performance Python package for reading and writing .dbf files.
Written in Rust (using PyO3), it provides standard Python bindings designed specifically for large datasets, where traditional pure-Python solutions (like the standard dbf package) suffer from significant performance bottlenecks.
Status
fastdbf is fully production-ready for core data exchange workloads.
Supported Features
- High-Performance I/O: Lightning fast reads and writes of standard
.dbffiles. - Zero-Copy Bulk Transfers: Native Apache Arrow integration (
to_arrow(),extend_arrow()) for high-speed exchange with Pandas/Polars. - Visual FoxPro Support: Direct handling of VFP
.dbfflavors, including mandatory null-flag layouts. - Memo Fields: Automatic management of companion
.fptmemo files for unbounded strings. - Strict Typing: Clear data mappings with custom exception classes (
DbfFormatError).
Not Implemented yet
- In-place Schema Modification: Dynamic addition/removal of columns on pre-written tables (currently raises
UnsupportedDbfTypeError). - Advanced Engine Tools: Indexing, cross-table relationships, or built-in query paradigms.
Installation
Create or sync the development environment with uv:
uv sync
Install into the current environment with uv:
uv pip install .
Editable install:
uv pip install -e .
Run tests:
uv run pytest
Build a wheel:
uv build
Quick Start
Read an existing DBF file:
import fastdbf
with fastdbf.Table("people.dbf").open("r") as table:
print(table.kind)
print(table.field_names)
print(table.record_count)
print(table.row(0))
for field in table.fields():
print(field["name"], field["type_code"], field["nullable"])
for row in table:
print(row)
Create and write a new DBF file:
import fastdbf
specs = "name C(25) null; age N(3,0) null; birth D null; active L null"
with fastdbf.Table("people.dbf", specs, dbf_type="vfp") as table:
table.append({
"NAME": "Spunky",
"AGE": 23,
"BIRTH": "1989-07-23",
"ACTIVE": True,
})
table.append({
"NAME": None,
"AGE": None,
"BIRTH": None,
"ACTIVE": None,
})
Field Types
Currently supported field types:
CCharacterDDateLLogicalNNumericFFloatIIntegerBDoubleT/@DateTimeYCurrencyM/G/Pas reference values
Nullable fields are supported through null or nullable modifiers in the field specification:
"name C(25) null; amount N(10,2) nullable; created T null"
Nullable fields should be used with dbf_type="vfp" for Visual FoxPro-compatible null flags.
pandas Example
import pandas as pd
import fastdbf
with fastdbf.Table("input.dbf").open("r") as table:
df = pd.DataFrame(list(table))
df["NAME"] = df["NAME"].str.upper()
field_specs = []
for field in table.fields():
code = field["type_code"]
nullable = " null" if field["nullable"] else ""
if code == "C":
field_specs.append(f'{field["name"]} C({field["length"]}){nullable}')
elif code in ("N", "F"):
field_specs.append(
f'{field["name"]} {code}({field["length"]},{field["decimals"]}){nullable}'
)
else:
field_specs.append(f'{field["name"]} {code}{nullable}')
dbf_type = "vfp" if any(f["nullable"] for f in table.fields()) else "db3"
specs = "; ".join(field_specs)
with fastdbf.Table("output.dbf", specs, dbf_type=dbf_type) as out:
for row in df.to_dict(orient="records"):
out.append(row)
Performance & Columnar I/O (Arrow)
For maximum performance, especially with large datasets, fastdbf provides columnar read/write interfaces that avoid the high overhead of Python object allocation.
1. Apache Arrow Interface (Zero-Copy) — Fastest
Leverages the Arrow PyCapsule Interface to exchange data directly between Rust and Pandas / Polars / PyArrow without copying.
Read into Pandas via Arrow:
import fastdbf
import pyarrow as pa
with fastdbf.Table("data.dbf").open("r") as table:
# Arrow Batch -> Pandas DataFrame
df = pa.Table.from_batches([pa.record_batch(table.to_arrow())]).to_pandas()
Write from Pandas via Arrow:
import fastdbf
import pyarrow as pa
# Create Arrow batch from DataFrame
batch = pa.RecordBatch.from_pandas(df)
with fastdbf.Table("output.dbf", field_specs="NAME C(20); AGE N(10,2)") as table:
table.extend_arrow(batch)
2. Columnar Interface (to_columns, extend_columns)
Reads/writes data as a dictionary of lists (one list per column). Faster than row-by-row processing but still bound by GIL limits.
Bulk Columnar Read:
import pandas as pd
import fastdbf
with fastdbf.Table("data.dbf").open("r") as table:
cols = table.to_columns()
df = pd.DataFrame(cols)
Bulk Columnar Write:
import pandas as pd
import fastdbf
# Assuming df ist das Pandas DataFrame
# Optionale interne Meta-Spalten wie '_deleted' entfernen
clean_data = {col: df[col].tolist() for col in df.columns if col != "_deleted"}
with fastdbf.Table("output.dbf", field_specs="NAME C(20); AGE N(10,2)") as table:
table.extend_columns(clean_data)
Overview: Read/Write Methods compared
| Method | Implementation | Pros |
|---|---|---|
| Row-by-Row | table.row(), table.append() |
Easiest to use |
| Bulk Columnar | to_columns(), extend_columns() |
No heavy dependencies |
| Zero-Copy Arrow | to_arrow(), extend_arrow() |
Direct memory exchange |
Documentation
Full Python API documentation:
Changelog:
Rust Example
use fastdbf::{Date, Table, Value};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut table = Table::new("name C(25); age N(3,0); birth D; qualified L")?;
let mut record = table.new_record();
record.insert(table.fields(), "name", Value::Character("Spunky".into()))?;
record.insert(table.fields(), "age", Value::Numeric(23.0))?;
record.insert(table.fields(), "birth", Value::Date(Some(Date::new(1989, 7, 23))))?;
record.insert(table.fields(), "qualified", Value::Logical(Some(true)))?;
table.push_record(record)?;
table.write_to_path("example.dbf")?;
Ok(())
}
License
This project is licensed under the Apache License 2.0.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastdbf-0.4.4.tar.gz.
File metadata
- Download URL: fastdbf-0.4.4.tar.gz
- Upload date:
- Size: 282.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
925b51d481ef17fd189dc92c1808129ac74c7786335812a76318b98476c0b331
|
|
| MD5 |
fbcc22b2ea6b2c69221f443df51e4267
|
|
| BLAKE2b-256 |
bdfc3ac4e7292b027bf325f6bfa8d532c7171ac950619a8de0051cc0c17ff992
|
Provenance
The following attestation bundles were made for fastdbf-0.4.4.tar.gz:
Publisher:
release.yml on Jonas-Bruns/fastdbf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastdbf-0.4.4.tar.gz -
Subject digest:
925b51d481ef17fd189dc92c1808129ac74c7786335812a76318b98476c0b331 - Sigstore transparency entry: 1404306919
- Sigstore integration time:
-
Permalink:
Jonas-Bruns/fastdbf@1bf1d75a4f6c333a61d4026ff9897a5397ddabf6 -
Branch / Tag:
refs/tags/v0.4.4 - Owner: https://github.com/Jonas-Bruns
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1bf1d75a4f6c333a61d4026ff9897a5397ddabf6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastdbf-0.4.4-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: fastdbf-0.4.4-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.11+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c2c2950869e1514e550a7681cc2868ae9c23a8bfb69f14dad6e03fd537ed211
|
|
| MD5 |
f33e784ee7f67054e633e90a4aba14eb
|
|
| BLAKE2b-256 |
532ac71baba0f551a476024332116e746718decae26a009b48230f457d946ab8
|
Provenance
The following attestation bundles were made for fastdbf-0.4.4-cp311-abi3-win_amd64.whl:
Publisher:
release.yml on Jonas-Bruns/fastdbf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastdbf-0.4.4-cp311-abi3-win_amd64.whl -
Subject digest:
3c2c2950869e1514e550a7681cc2868ae9c23a8bfb69f14dad6e03fd537ed211 - Sigstore transparency entry: 1404307208
- Sigstore integration time:
-
Permalink:
Jonas-Bruns/fastdbf@1bf1d75a4f6c333a61d4026ff9897a5397ddabf6 -
Branch / Tag:
refs/tags/v0.4.4 - Owner: https://github.com/Jonas-Bruns
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1bf1d75a4f6c333a61d4026ff9897a5397ddabf6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastdbf-0.4.4-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: fastdbf-0.4.4-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bffd59501473d5bf657a7547809113798d589efaee15db49b15a614860b061fa
|
|
| MD5 |
f6a861d92d6801d328b95dcc8cd17289
|
|
| BLAKE2b-256 |
9538c686567bba9766ba6cf30b8be53f1cabe83dd8b1142e4304f9af26db86c5
|
Provenance
The following attestation bundles were made for fastdbf-0.4.4-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on Jonas-Bruns/fastdbf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastdbf-0.4.4-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
bffd59501473d5bf657a7547809113798d589efaee15db49b15a614860b061fa - Sigstore transparency entry: 1404307553
- Sigstore integration time:
-
Permalink:
Jonas-Bruns/fastdbf@1bf1d75a4f6c333a61d4026ff9897a5397ddabf6 -
Branch / Tag:
refs/tags/v0.4.4 - Owner: https://github.com/Jonas-Bruns
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1bf1d75a4f6c333a61d4026ff9897a5397ddabf6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastdbf-0.4.4-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: fastdbf-0.4.4-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04613bb96d01b842b28942e9f3a26117cb416b83c9f250de64f004edf865c6fd
|
|
| MD5 |
329fb12a7bf4e062b1328c4f8cc07547
|
|
| BLAKE2b-256 |
b4f77f6aa3ae87140dc086123e42f13bfbac569d55d1a32304cf8f1872dea9cc
|
Provenance
The following attestation bundles were made for fastdbf-0.4.4-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on Jonas-Bruns/fastdbf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastdbf-0.4.4-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
04613bb96d01b842b28942e9f3a26117cb416b83c9f250de64f004edf865c6fd - Sigstore transparency entry: 1404307044
- Sigstore integration time:
-
Permalink:
Jonas-Bruns/fastdbf@1bf1d75a4f6c333a61d4026ff9897a5397ddabf6 -
Branch / Tag:
refs/tags/v0.4.4 - Owner: https://github.com/Jonas-Bruns
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1bf1d75a4f6c333a61d4026ff9897a5397ddabf6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastdbf-0.4.4-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastdbf-0.4.4-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27bd10cc4cb51c1a523d549369250f7bd3525d9626b113682a6a33a94ee9a69b
|
|
| MD5 |
363392a1b0872fdcac1ecc090033a449
|
|
| BLAKE2b-256 |
cbd5abbfa5c1dd16b07794e475573521b6a819393b2cda7e7f4971b6b80ee32f
|
Provenance
The following attestation bundles were made for fastdbf-0.4.4-cp311-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on Jonas-Bruns/fastdbf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastdbf-0.4.4-cp311-abi3-macosx_11_0_arm64.whl -
Subject digest:
27bd10cc4cb51c1a523d549369250f7bd3525d9626b113682a6a33a94ee9a69b - Sigstore transparency entry: 1404307456
- Sigstore integration time:
-
Permalink:
Jonas-Bruns/fastdbf@1bf1d75a4f6c333a61d4026ff9897a5397ddabf6 -
Branch / Tag:
refs/tags/v0.4.4 - Owner: https://github.com/Jonas-Bruns
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1bf1d75a4f6c333a61d4026ff9897a5397ddabf6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastdbf-0.4.4-cp311-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: fastdbf-0.4.4-cp311-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.11+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9aa5302d2c6280e933273b3d3eb1fe874fa0299f9ec169d24d458bc59fb7d4ac
|
|
| MD5 |
208683411fc818eb4a01e540b28dfcae
|
|
| BLAKE2b-256 |
5a8b12a0c8f239362e39c6adfb2792e09a43548347122536b1270ccff2cca45b
|
Provenance
The following attestation bundles were made for fastdbf-0.4.4-cp311-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on Jonas-Bruns/fastdbf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastdbf-0.4.4-cp311-abi3-macosx_10_12_x86_64.whl -
Subject digest:
9aa5302d2c6280e933273b3d3eb1fe874fa0299f9ec169d24d458bc59fb7d4ac - Sigstore transparency entry: 1404307353
- Sigstore integration time:
-
Permalink:
Jonas-Bruns/fastdbf@1bf1d75a4f6c333a61d4026ff9897a5397ddabf6 -
Branch / Tag:
refs/tags/v0.4.4 - Owner: https://github.com/Jonas-Bruns
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1bf1d75a4f6c333a61d4026ff9897a5397ddabf6 -
Trigger Event:
push
-
Statement type: