Skip to content

frankyxhl/dbfpy3

Repository files navigation

dbfpy3

Python Version PyPI Version License Tests

Pure Python 3 library for reading and writing DBF (dBase/FoxPro) database files. No external dependencies required.

✨ Features

  • Pure Python - No C extensions or external dependencies
  • FoxPro Support - Full support for FoxPro DBF files and memo fields (.FPT)
  • Code Page Support - Proper character encoding for international data
  • Context Manager - Safe resource management with with statements
  • Python 3.5+ - Modern Python support

🚀 Quick Start

Installation

pip install dbfpy3

Basic Usage

from dbfpy3 import dbf

# Read existing DBF file
with dbf.Dbf('customers.dbf') as db:
    for record in db:
        print(record['NAME'], record['EMAIL'])

# Create new DBF file
db = dbf.Dbf('new_file.dbf', new=True)
db.add_field(
    ('C', 'NAME', 30),      # Character field, max 30 chars
    ('D', 'BIRTHDATE'),     # Date field
    ('N', 'SALARY', 10, 2), # Numeric field, 10 digits, 2 decimal places
    ('L', 'ACTIVE')         # Logical field (True/False)
)

# Add records
rec = db.new()
rec['NAME'] = 'John Doe'
rec['BIRTHDATE'] = datetime.date(1990, 1, 15)
rec['SALARY'] = 75000.50
rec['ACTIVE'] = True
db.write(rec)
db.close()

📖 Documentation

🧪 Development

# Clone repository
git clone https://github.com/frankyxhl/dbfpy3.git
cd dbfpy3

# Install development dependencies
pip install -r requirements_dev.txt

# Run tests
python -m unittest discover tests
make test

# Run specific test module
python -m unittest tests.test_fields

# Check code style
make lint

⚠️ Important Notes

  • Field Names: Limited to 10 characters per DBF specification
  • Unicode Support: DBF files use code pages for character encoding
  • Production Use: While functional, use with caution in production environments

📄 License

This project is licensed under the BSD License - see the LICENSE file for details.

🙏 Credits

  • Original Author: Jeff Kunce
  • Python 3 Port: Frank Xu
  • Contributors: Hans Fiby, Zdeněk Böhm, and many others

🔗 Links

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •