Skip to main content

A Python library to manipulate DBase III database files

Project description

DBase III Python Library

This project provides a Python library to manipulate DBase III database files. It allows reading, writing, adding, and updating records in the database.

Even though this file format for databases is largely no longer in use, the present work is a minitool useful to retrieve legacy data, as much as a tribute to a beautiful part of computer history.

Features

  • Read DBase III database files
  • Write to DBase III database files
  • Add new records
  • Update existing records
  • Filter and search records

Installation

To install the library, clone this repository and navigate to the project directory:

git clone https://github.com/sandy98/dbase3-py.git
cd dbase3-py

Usage

from dbase3 import DBaseFile, FieldType
test = DbaseFile.create('db/test.dbf',
                    [('name', FieldType.CHARACTER.value, 50, 0),
                        ('age', FieldType.NUMERIC.value, 3, 0)])
test.add_record('John Doe', 30)
test.add_record('Jane Doe', 25)

print(test)
print(len(test))
print(test[:])
print(test.filter('name', 'ja', comp_func=self.istartswith))

The module itself, DBaseFile class and all its methods are thoroughly documented, so it should be easy to follow up.

Documentation

Classes

DBaseFile

Class to manipulate DBase III database files.

  • __init__(self, filename: str): Initializes an instance of DBase3.
  • __del__(self): Closes the database file when the instance is destroyed.
  • init(self): Initializes the database structure by reading the header and fields.

add_record(self, record_data: dict)

: Adds a new record to the database.

  • update_record(self, index: int, record_data: dict): Updates an existing record in the database.
  • istartswith(f: str, v: str) -> bool: Checks if the string f starts with the string v, ignoring case.
  • iendswith(f: str, v: str) -> bool: Checks if the string f ends with the string v, ignoring case.

create(cls, filename: str, fields: List[Tuple[str, FieldType, int, int]])

: Creates a new DBase III database file with the specified fields.

Methods

  • dump_record(self, key, record): Writes a record (dictionary with field names and field values) to the database at the specified index.
  • __len__(self): Returns the number of records in the database, including records marked to be deleted.
  • __getitem__(self, key): Returns a single record or a list of records from the database.
  • __iter__(self): Returns an iterator over the records in the database.
  • __str__(self): Returns a string representation of the database.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For any questions or suggestions, please contact Domingo E. Savoretti.



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

dbase3_py-0.1.13.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbase3_py-0.1.13-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file dbase3_py-0.1.13.tar.gz.

File metadata

  • Download URL: dbase3_py-0.1.13.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.0rc1

File hashes

Hashes for dbase3_py-0.1.13.tar.gz
Algorithm Hash digest
SHA256 8f40821be67eaebcc23d106a321a42ac40274996aa89f360bdb0520ef7d87b49
MD5 e97caff6b10c4d9ee68aca13897b1dc8
BLAKE2b-256 a804c0a93691f9e51e9d30d7b8ce9708e4bb73e8240218f2e16bcb15c2d7af82

See more details on using hashes here.

File details

Details for the file dbase3_py-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: dbase3_py-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.0rc1

File hashes

Hashes for dbase3_py-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 b4386734190d286b163a5bdfe6f196b01bb04109cd28f8d4826a7a6a839ca3ff
MD5 232c8da621b81df45da27289c0912f59
BLAKE2b-256 e702b5bcc2a3528c759ea0702fc4e4e3c8963c8d5fea8425989fa9e01d4db472

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page