parquetdb


Nameparquetdb JSON
Version 0.25.1 PyPI version JSON
download
home_pageNone
SummaryParquetDB is a lightweight database-like system built on top of Apache Parquet files using PyArrow.
upload_time2025-02-16 03:59:41
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2023 lllangWV Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords parquet pyarrow data storage schema evolution nested and complex data types scalable database python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ParquetDB

**ParquetDB** is a Python library designed to bridge the gap between traditional file storage and fully fledged databases, all while wrapping the powerful PyArrow library to streamline data input and output. By leveraging the Parquet file format, ParquetDB provides the portability and simplicity of file-based data storage alongside advanced querying features typically found in database systems.

## Table of Contents

- [ParquetDB](#parquetdb)
  - [Table of Contents](#table-of-contents)
  - [Documentation](#documentation)
  - [Features](#features)
  - [Installation](#installation)
  - [Usage](#usage)
    - [Creating a Database](#creating-a-database)
    - [Adding Data](#adding-data)
    - [Normalizing](#normalizing)
    - [Reading Data](#reading-data)
    - [Updating Data](#updating-data)
    - [Deleting Data](#deleting-data)
  - [Citing ParquetDB](#citing-parquetdb)
  - [Contributing](#contributing)
  - [License](#license)

## Documentation

Check out the [docs](https://lllangwv.github.io/ParquetDB/)

## Features

- **Simple Interface**: Easy-to-use methods for creating, reading, updating, and deleting data.
- **Minimal Overhead**: Achieve quick read/write speeds without the complexity of setting up or managing a larger database system.
- **Batching**: Efficiently handle large datasets by batching operations.
- **Supports Complex Data Types**: Handles nested and complex data types.
- **Schema Evolution**: Supports adding new fields and updating schemas seamlessly.
- **Supports storing of python objects**: ParquetDB can store python objects (objects and functions) using pickle.
- **Supports np.ndarrays**: ParquetDB can store ndarrays.

## Installation

Install ParquetDB using pip:

```bash
pip install parquetdb
```

## Usage

### Creating a Database

Initialize a ParquetDB instance by specifying the path the name of the dataset

```python
from parquetdb import ParquetDB

db = ParquetDB(dataset_name='parquetdb')
```

### Adding Data

Add data to the database using the `create` method. Data can be a dictionary, a list of dictionaries, or a Pandas DataFrame.

```python
data = [
    {'name': 'Charlie', 'age': 28, 'occupation': 'Designer'},
    {'name': 'Diana', 'age': 32, 'occupation': 'Product Manager'}
]

db.create(data)
```

### Normalizing

Normalization is a crucial process for ensuring the optimal performance and efficient management of data. In the context of file-based databases, like the ones used in ParquetDB, normalization helps balance the distribution of data across multiple files. Without proper normalization, files can end up with uneven row counts, leading to performance bottlenecks during operations like queries, inserts, updates, or deletions.

This method does not return anything but modifies the dataset directory in place, ensuring a more consistent and efficient structure for future operations.

```python
db.normalize(
    normalize_config=NormalizeConfig(
    load_format='batches',      # Uses the batch generator to normalize
    batch_readahead=10,         # Controls the number of batches to load in memory a head of time.
    fragment_readahead=2,       # Controls the number of files to load in memory ahead of time.
    batch_size = 100000,        # Controls the batchsize when to use when normalizing. This will have impacts on amount of RAM consumed
    max_rows_per_file=500000,   # Controls the max number of rows per parquet file
    max_rows_per_group=500000)  # Controls the max number of rows per group parquet file
)
```

### Reading Data

Read data from the database using the `read` method. You can filter data by IDs, specify columns, and apply filters.

```python
# Read all data
all_employees = db.read()

# Read specific columns
names = db.read( columns=['name'])

# Read data with filters
from pyarrow import compute as pc

age_filter = pc.field('age') > 30
older_employees = db.read(filters=[age_filter])
```

### Updating Data

Update existing records in the database using the `update` method. Each record must include the `id` field.

```python
update_data = [
    {'id': 1, 'occupation': 'Senior Engineer'},
    {'id': 3, 'age': 29}
]

db.update(update_data)
```

### Deleting Data

Delete records from the database by specifying their IDs.

```python
db.delete(ids=[2, 4])
```

## Citing ParquetDB

If you use ParquetDB in your work, please cite the following paper:

```bibtex
    @misc{lang2025parquetdblightweightpythonparquetbased,
      title={ParquetDB: A Lightweight Python Parquet-Based Database}, 
      author={Logan Lang and Eduardo Hernandez and Kamal Choudhary and Aldo H. Romero},
      year={2025},
      eprint={2502.05311},
      archivePrefix={arXiv},
      primaryClass={cs.DB},
      url={https://arxiv.org/abs/2502.05311}}
```

## Contributing

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

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

---

*Note: This project is in its initial stages. Features and APIs are subject to change. Please refer to the latest documentation and release notes for updates.*

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "parquetdb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "parquet, pyarrow, data, storage, schema evolution, nested and complex data types, scalable, database, python",
    "author": null,
    "author_email": "Logan Lang <lllang@mix.wvu.edu>, Aldo Romero <Aldo.Romero@mail.wvu.edu>, Kamal Choudhary <kamal.choudhary@nist.gov>, Eduardo Hernandez <Eduardo.Hernandez@csic.es>",
    "download_url": "https://files.pythonhosted.org/packages/8b/4b/d72b319916052e7fdff3c251e30dce0506624d2a5dc1eee82156631f9190/parquetdb-0.25.1.tar.gz",
    "platform": null,
    "description": "# ParquetDB\n\n**ParquetDB** is a Python library designed to bridge the gap between traditional file storage and fully fledged databases, all while wrapping the powerful PyArrow library to streamline data input and output. By leveraging the Parquet file format, ParquetDB provides the portability and simplicity of file-based data storage alongside advanced querying features typically found in database systems.\n\n## Table of Contents\n\n- [ParquetDB](#parquetdb)\n  - [Table of Contents](#table-of-contents)\n  - [Documentation](#documentation)\n  - [Features](#features)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Creating a Database](#creating-a-database)\n    - [Adding Data](#adding-data)\n    - [Normalizing](#normalizing)\n    - [Reading Data](#reading-data)\n    - [Updating Data](#updating-data)\n    - [Deleting Data](#deleting-data)\n  - [Citing ParquetDB](#citing-parquetdb)\n  - [Contributing](#contributing)\n  - [License](#license)\n\n## Documentation\n\nCheck out the [docs](https://lllangwv.github.io/ParquetDB/)\n\n## Features\n\n- **Simple Interface**: Easy-to-use methods for creating, reading, updating, and deleting data.\n- **Minimal Overhead**: Achieve quick read/write speeds without the complexity of setting up or managing a larger database system.\n- **Batching**: Efficiently handle large datasets by batching operations.\n- **Supports Complex Data Types**: Handles nested and complex data types.\n- **Schema Evolution**: Supports adding new fields and updating schemas seamlessly.\n- **Supports storing of python objects**: ParquetDB can store python objects (objects and functions) using pickle.\n- **Supports np.ndarrays**: ParquetDB can store ndarrays.\n\n## Installation\n\nInstall ParquetDB using pip:\n\n```bash\npip install parquetdb\n```\n\n## Usage\n\n### Creating a Database\n\nInitialize a ParquetDB instance by specifying the path the name of the dataset\n\n```python\nfrom parquetdb import ParquetDB\n\ndb = ParquetDB(dataset_name='parquetdb')\n```\n\n### Adding Data\n\nAdd data to the database using the `create` method. Data can be a dictionary, a list of dictionaries, or a Pandas DataFrame.\n\n```python\ndata = [\n    {'name': 'Charlie', 'age': 28, 'occupation': 'Designer'},\n    {'name': 'Diana', 'age': 32, 'occupation': 'Product Manager'}\n]\n\ndb.create(data)\n```\n\n### Normalizing\n\nNormalization is a crucial process for ensuring the optimal performance and efficient management of data. In the context of file-based databases, like the ones used in ParquetDB, normalization helps balance the distribution of data across multiple files. Without proper normalization, files can end up with uneven row counts, leading to performance bottlenecks during operations like queries, inserts, updates, or deletions.\n\nThis method does not return anything but modifies the dataset directory in place, ensuring a more consistent and efficient structure for future operations.\n\n```python\ndb.normalize(\n    normalize_config=NormalizeConfig(\n    load_format='batches',      # Uses the batch generator to normalize\n    batch_readahead=10,         # Controls the number of batches to load in memory a head of time.\n    fragment_readahead=2,       # Controls the number of files to load in memory ahead of time.\n    batch_size = 100000,        # Controls the batchsize when to use when normalizing. This will have impacts on amount of RAM consumed\n    max_rows_per_file=500000,   # Controls the max number of rows per parquet file\n    max_rows_per_group=500000)  # Controls the max number of rows per group parquet file\n)\n```\n\n### Reading Data\n\nRead data from the database using the `read` method. You can filter data by IDs, specify columns, and apply filters.\n\n```python\n# Read all data\nall_employees = db.read()\n\n# Read specific columns\nnames = db.read( columns=['name'])\n\n# Read data with filters\nfrom pyarrow import compute as pc\n\nage_filter = pc.field('age') > 30\nolder_employees = db.read(filters=[age_filter])\n```\n\n### Updating Data\n\nUpdate existing records in the database using the `update` method. Each record must include the `id` field.\n\n```python\nupdate_data = [\n    {'id': 1, 'occupation': 'Senior Engineer'},\n    {'id': 3, 'age': 29}\n]\n\ndb.update(update_data)\n```\n\n### Deleting Data\n\nDelete records from the database by specifying their IDs.\n\n```python\ndb.delete(ids=[2, 4])\n```\n\n## Citing ParquetDB\n\nIf you use ParquetDB in your work, please cite the following paper:\n\n```bibtex\n    @misc{lang2025parquetdblightweightpythonparquetbased,\n      title={ParquetDB: A Lightweight Python Parquet-Based Database}, \n      author={Logan Lang and Eduardo Hernandez and Kamal Choudhary and Aldo H. Romero},\n      year={2025},\n      eprint={2502.05311},\n      archivePrefix={arXiv},\n      primaryClass={cs.DB},\n      url={https://arxiv.org/abs/2502.05311}}\n```\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request on GitHub.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n*Note: This project is in its initial stages. Features and APIs are subject to change. Please refer to the latest documentation and release notes for updates.*\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2023 lllangWV\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "ParquetDB is a lightweight database-like system built on top of Apache Parquet files using PyArrow.",
    "version": "0.25.1",
    "project_urls": {
        "Changelog": "https://github.com/romerogroup/ParquetDB/CHANGELOG.md",
        "Issues": "https://github.com/romerogroup/ParquetDB/issues",
        "Repository": "https://github.com/romerogroup/ParquetDB"
    },
    "split_keywords": [
        "parquet",
        " pyarrow",
        " data",
        " storage",
        " schema evolution",
        " nested and complex data types",
        " scalable",
        " database",
        " python"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4432e175bec1b4908e184f4b14d99021e566090ccdc33149c3eb4ac814d1eea2",
                "md5": "70f8447a4b5eb7f0c4b3a756ba67524c",
                "sha256": "d7f304a484b70437ec59a3cc16424e868bf46e0520b1ae5b4f8f7fa18f883f10"
            },
            "downloads": -1,
            "filename": "parquetdb-0.25.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "70f8447a4b5eb7f0c4b3a756ba67524c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 56128,
            "upload_time": "2025-02-16T03:59:38",
            "upload_time_iso_8601": "2025-02-16T03:59:38.969205Z",
            "url": "https://files.pythonhosted.org/packages/44/32/e175bec1b4908e184f4b14d99021e566090ccdc33149c3eb4ac814d1eea2/parquetdb-0.25.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8b4bd72b319916052e7fdff3c251e30dce0506624d2a5dc1eee82156631f9190",
                "md5": "e891238b0c9cb25108d9cda0da515330",
                "sha256": "32b48f8da5c79f2aaa4f173f18bab7eb36afe6f68c8aa7bd230d28fa839ba42c"
            },
            "downloads": -1,
            "filename": "parquetdb-0.25.1.tar.gz",
            "has_sig": false,
            "md5_digest": "e891238b0c9cb25108d9cda0da515330",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 11664393,
            "upload_time": "2025-02-16T03:59:41",
            "upload_time_iso_8601": "2025-02-16T03:59:41.600687Z",
            "url": "https://files.pythonhosted.org/packages/8b/4b/d72b319916052e7fdff3c251e30dce0506624d2a5dc1eee82156631f9190/parquetdb-0.25.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-16 03:59:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "romerogroup",
    "github_project": "ParquetDB",
    "github_not_found": true,
    "lcname": "parquetdb"
}
        
Elapsed time: 8.03824s