🚀 A modern Python library for reading DBF files with elegance and type safety
dbfread2
is a modern, type-safe Python library for reading DBF files (dBase, Visual FoxPro, FoxBase+) with zero external dependencies.
- 🐍 Modern Python 3.12+ implementation
- 🔍 Comprehensive type hints
- 🛠️ Simple yet powerful API
- 📁 Native
pathlib.Path
support - 🔄 Streaming and memory-loaded modes
- 📝 Support for all major DBF variants
- 📋 18 field types with extensible
FieldParser
- 📎 Reads
FPT
andDBT
memo files - 🔒 Type-safe operations
from dbfread2 import DBF
# Stream records (memory-efficient)
for record in DBF('people.dbf'):
print(record)
# {'NAME': 'Alice', 'BIRTHDATE': datetime.date(1987, 3, 1)}
# {'NAME': 'Bob', 'BIRTHDATE': datetime.date(1980, 11, 12)}
# Load all records into memory
table = DBF('people.dbf', preload=True)
print(table.records[0]['NAME']) # Returns: 'Alice'
pip install dbfread2
-
Python Version
- ✅ Python 3.12+ required
- ❌ No support for older versions
-
Import Updates
# Before ❌ from dbfread import DBF # After ✅ from dbfread2 import DBF
-
Modern Parameter Names
# Before ❌ DBF('file.dbf', recfactory=dict, lowernames=True) # After ✅ DBF('file.dbf', record_factory=dict, lowercase_names=True)
-
Path Support
# ✨ New Feature from pathlib import Path DBF(Path('data/file.dbf'))
-
Install Tools
- mise-en-place for environment management
- uv for package management
-
Clone & Setup
git clone https://github.com/wasdee/dbfread2.git cd dbfread2 mise install uv pip install -e ".[docs]"
mise run docs:build # Build docs
mise run docs:serve # Serve locally
mise run docs:watch # Watch mode
mise run docs:check # Check for issues
While dbfread2
focuses on reading DBF files, here are recommended libraries for writing DBF files:
-
dbf (by Ethan Furman)
- Most comprehensive DBF writer
- Supports multiple DBF formats (dBase III+, FP, VFP, Clipper)
- Rich field type support including memo fields
- Memory-efficient operations
- GitHub
-
pybase3
- Modern SQL-like interface
- Simple API focused on dBase III
- Active development
- Built-in CLI tools
- GitHub
-
ydbf
- Clean, modern Python implementation
- Streaming write support
- No external dependencies
- Good for basic DBF operations
- GitHub
Choose based on your needs:
- Use dbf for enterprise/legacy systems needing comprehensive format support
- Use pybase3 for modern, simple dBase III operations
- Use ydbf for basic operations with clean Python code
MIT License
Fork of dbfread by Ole Martin Bjørndalen
Nutchanon Ninyawee - [email protected]
⭐️ If this project helps you, consider giving it a star!