{"id":23985495,"url":"https://github.com/sandy98/pybase3","last_synced_at":"2026-02-27T16:33:38.773Z","repository":{"id":270644221,"uuid":"911007531","full_name":"sandy98/pybase3","owner":"sandy98","description":"Python driver for dBase III+ files","archived":false,"fork":false,"pushed_at":"2025-02-03T19:07:07.000Z","size":1808,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T15:47:27.993Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sandy98.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-02T03:14:20.000Z","updated_at":"2025-02-04T05:22:09.000Z","dependencies_parsed_at":"2025-01-02T04:31:32.506Z","dependency_job_id":"785bb8dd-c85b-4c78-8a01-fc26464bbbdf","html_url":"https://github.com/sandy98/pybase3","commit_stats":null,"previous_names":["sandy98/pybase3"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandy98%2Fpybase3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandy98%2Fpybase3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandy98%2Fpybase3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandy98%2Fpybase3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sandy98","download_url":"https://codeload.github.com/sandy98/pybase3/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248859662,"owners_count":21173337,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-07T14:15:26.275Z","updated_at":"2026-02-27T16:33:33.728Z","avatar_url":"https://github.com/sandy98.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/sandy98/pybase3/main/img/pybase3t.png\" alt=\"pybase3 logo\"\u003e\n\u003c/p\u003e\n\n\u003c!--![PyPI - Current Version](https://img.shields.io/pypi/v/pybase3)--\u003e\n\n\u003cp\u003e\n  \u003ca href=\"https://pypi.org/project/pybase3\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/pybase3\" alt=\"PyPI - Current Version\"\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/pypi/dm/pybase3\"\u003e\n\u003c/p\u003e\n\n# DBase III Python Library\n\nPython library meant to manipulate DBase III database files. It allows reading, writing, adding, and updating records in the database.\n\nBeginning with version 1.90. ...  classes Connection and Cursor were added, beginning the road to fully conformance with  Python Database API Specification v2.0 (PEP 249).\nTo this point, both Cursor and Connection support `execute` method, which accepts `select, insert, update and delete` commands. Further support for SQL (`create, etc`) is underway.\nThis features work in a stable manner as of version 1.98.3, even though there are some use limitations, mainly the fact that right now, queries are 'table-centered', meaning they don't work on more than one table at a time. This will be adressed in future versions, as it is a requisite to become fully conformant.\nHopefully pybase3 will become listed with the other Python DB API conformant modules (Sqlite3, MySQL, Postgre, etc)\n\nEven though this file format for databases is largely no longer in use, the present work is a useful tool to retrieve legacy data, as much as a tribute to a beautiful part of computer history.\n\nInitiating from versions updated on 2025-01-04, `pybase3` supports indexing through `.pmdx` files (Python + .mdx), which results in astonishingly fast queries. See below for details.\n\n## Features\n- Connection and Cursor DB API classes\n- Read DBase III database files\n- Write to DBase III database files\n- Add new records\n- Update existing records\n- Filter and search records\n- Import from/ export to `.csv` files. (New in v. 1.12.1) See `import_from` and `export_to`\n- Import from/ export to `sqlite` databases. (New in v. 1.13.1) See `import_from` and `export_to`\n\n## Installation\n\nTo install the library, use `pip` to download it from Pypi. This is the preferred method: \n\n```bash\npip install pybase3\n```\n\nor clone the repository and navigate to the project directory:\n\n```bash\ngit clone https://github.com/sandy98/pybase3.git\ncd pybase3\n```\n\n## Usage\n\n### `Connection` class\n\n```python\nimport pybase3\nfrom pybase3 import Connection\n\n# Connects to 'db' directory. All .dbf files within will be included.\nconn = Connection('db') \n# Gets a Cursor object from the connection by executing a SQL command\ncurr = conn.execute('select id, nombre as name, titles from teams order by titles desc;')\n# Hands the cursor to a data formatting function \nfor line in pybase3.make_pretty_table_lines(curr):\n  print(line)\n# or, alternatively, invokes a method of the cursor objects to retrieve the rows\ncurr = conn.execute('select id, nombre as name, titles from teams order by titles desc;')\nrows = curr.fetchall()\nprint(f\"{len(rows)} records retrieved.\")\n```\n\n### `DbaseFile` class\n\n```python\nfrom pybase3 import DBaseFile, FieldType\ntest = DbaseFile.create('db/test.dbf',\n                    [('name', FieldType.CHARACTER.value, 50, 0),\n                        ('age', FieldType.NUMERIC.value, 3, 0)])\ntest.add_record('John Doe', 30)\ntest.add_record('Jane Doe', 25)\n\nprint(test)\nprint(len(test))\nprint(test[:])\nprint(test.filter('name', 'ja', compare_function=self.istartswith))\n\n```\n\n### `dbfquery` utility\n\n```bash\ndbfquery \u003cdbf_directory\u003e\n\n# Example of use\n\n$ dbfquery db\n\nWelcome to pybase3 SQL shell v. 1.98.7\nSQL for dBase III+\nWorking directory: /home/ernesto/Programas/2025/python/pybase3 / 22 tables found.\nType 'help' for help.\n\nsql\u003e select * from teams where titles \u003e 40 order by titles desc;\n\n┌────┬──────────────────────────────────────────────────┬──────┐\n│ id │                      nombre                      │titles│\n├────┼──────────────────────────────────────────────────┼──────┤\n│   1│River Plate                                       │    77│\n├────┼──────────────────────────────────────────────────┼──────┤\n│   2│Boca Juniors                                      │    75│\n├────┼──────────────────────────────────────────────────┼──────┤\n│   3│Racing Club                                       │    47│\n├────┼──────────────────────────────────────────────────┼──────┤\n│  13│Sarmiento de Junín                                │    43│\n└────┴──────────────────────────────────────────────────┴──────┘\n\nsql\u003e quit \nBye, thank you for using SQL with dBase III\n\n```\n\n### Database browser utility\n\n```bash\npython3 dbfview.py \u003cdbf_file\u003e\n```\n\nor, even better, if pybase3 is installed using pip, it will install dbfview as a script, thus:\n\n```bash\ndbfview \u003cdbf_file\u003e\n```\n\nA convenient CLI cursed based utility to browse .dbf files.\n\n### Test utility\n\n```bash\npython3 dbftest.py [-r|-d]\n```\n\nor, even better, if pybase3 is installed using pip, it will install dbftest as a script, thus:\n\n```bash\ndbftest  [-r|-d]\n```\n\nThis is a simple test script for the pybase3 module.\nIt creates a test database (`db/test.dbf`), updates some records, and deletes one.\nIt then writes the changes to the database file.\nThe script can be run with the -d option to show intermediate results or the -r option to erase an existing test.dbf.\nThe script will create a directory 'db' in the current directory if it doesn't exist.\nThe script will create a file 'test.dbf' in the 'db' directory if it doesn't exist.\n\n### Module level usage\n\nBy issuing the command:\n\n```bash\npython3 -m pybase3 [-v|-i|-h]\n```\n\nthe module itself is invoked (more specifically, __main__.py), resulting in a traversal of the file system lookinf for .dbf files. At the end, should the search be successful, the user is offered with a numbered menu of existing dbf files, ready to be read by dbfview.\n\nAs of version 1.9.5 new options were added: -v, --version for retrieving current version of the software, -i, --info for getting full information, and -h, --help for usage instructions.\n\nA command line option ``pybase3`` was also added in version 1.9.5 , which works the same way as invoking the module, for example:\n\n```bash\npybase3 [-v|-i|-h]\n```\n\n### Comments\n\nThe module itself, DBaseFile class and all its methods are thoroughly documented, so it should be easy to follow up.\n\nEsentially, each instance of DBaseFile, be it instanced through an existing DBase III file, or created through the factory method DBaseFile.create(filename), is a list like object with indexing capabilities, which also acts as an iterator through the records present in the .dbf file. It also supports the 'len' method, reporting the number of records present in the database, even those marked for deletion.\nOn top of that, there is a group of methods meant for data manipulation (add_record for inserts, update_record for updates and del_record for marking/unmarking deletions).\nThere is also a group of methods (search, index, find, filter) to aid in retrieving selected data.\n\nAt it present stage of development, there is not support for memo fields or index fields, though this is planned for future releases, should enough interest arise.\nVersion 1.14.2 added `execute` method to execute SQL-like statements returning a cursor object.\n\nFor further information see:\n\n\u003ca href=\"docs/pybase3.md\"\u003ePybase3 Docs\u003c/a\u003e\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## Contact\n\nFor any questions or suggestions, please contact [Domingo E. Savoretti](mailto:esavoretti@gmail.com).\n\n```\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandy98%2Fpybase3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsandy98%2Fpybase3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandy98%2Fpybase3/lists"}