matdb


Namematdb JSON
Version 0.0.10 PyPI version JSON
download
home_pageNone
SummaryWelcome to MatDB, a material science database designed to be light weight and portable.
upload_time2024-10-03 02:06:09
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 materials science database python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MatDB

MatDB is a material science database designed to be light weight and portable. It is built on top of Apache Parquet files using PyArrow, which reduces the overhead of serialization and allows for efficient storage and retrieval of complex data types.

## Table of Contents

- [Features](#features)
- [Why MatDB?](#why-matdb)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Usage](#usage)
  - [Creating a Database](#creating-a-database)
  - [Adding Data](#adding-data)
  - [Reading Data](#reading-data)
  - [Updating Data](#updating-data)
  - [Deleting Data](#deleting-data)
- [API Reference](#api-reference)
- [Contributing](#contributing)
- [License](#license)

## Features

- **Simple Interface**: Easy-to-use methods for creating, reading, updating, and deleting data.
- **High Performance**: Utilizes Apache Parquet and PyArrow for efficient data storage and retrieval.
- **Supports Complex Data Types**: Handles nested and complex data types without serialization overhead.
- **Scalable**: Designed to handle large datasets efficiently.
- **Schema Evolution**: Supports adding new fields and updating schemas seamlessly.

## Roadmap

- Support foriegn keys use
- Multiprocessing for reading and writing
- Increase support for nested structures

## Why MatDB?

### The Challenge of Serialization and Deserialization

In many data processing and machine learning workflows, a significant performance bottleneck occurs during the serialization and deserialization of data. Serialization is the process of converting complex data structures or objects into a format that can be easily stored or transmitted, while deserialization is the reverse process of reconstructing these objects from the serialized format.

The need for serialization arises when:
1. Storing data on disk
2. Transmitting data over a network
3. Caching data in memory

However, serialization and deserialization can be computationally expensive, especially when dealing with large datasets or complex object structures. This process can lead to:

- Increased I/O operations
- Higher CPU usage
- Increased memory consumption
- Longer processing times

These issues become particularly problematic in machine learning pipelines, where data needs to be frequently loaded, processed, and saved. The overhead of constantly serializing and deserializing data can significantly slow down the entire workflow, affecting both development iteration speed and production performance.

### How Parquet Files Address the Serialization Challenge

Apache Parquet files offer a solution to the serialization/deserialization problem by providing:

1. **Columnar Storage Format**: Parquet stores data in a columnar format, which allows for efficient compression and encoding schemes. This format is particularly beneficial for analytical queries that typically involve a subset of columns.
2. **Schema Preservation**: Parquet files store the schema of the data along with the data itself. This eliminates the need for separate schema definitions and reduces the risk of schema mismatch errors.
3. **Efficient Encoding**: Parquet uses advanced encoding techniques like dictionary encoding, bit packing, and run length encoding, which can significantly reduce file sizes and improve read performance.
4. **Predicate Pushdown**: Parquet supports predicate pushdown, allowing queries to skip irrelevant data blocks entirely, further improving query performance.
5. **Compatibility**: Parquet files are compatible with various big data processing frameworks, making it easier to integrate into existing data pipelines.

By leveraging these features, ParquetDB eliminates the need for explicit serialization and deserialization of complex data types. Data can be read directly from and written directly to Parquet files, maintaining its structure and allowing for efficient querying and processing.

### The MatDB Advantage

MatDB builds upon the benefits of Parquet files by providing:

1. A simple, database-like interface for working with Parquet files
2. Efficient storage and retrieval of complex data types
3. High-performance data operations leveraging PyArrow's computational capabilities
4. Seamless integration with machine learning pipelines and data processing workflows

By using MatDB, developers and data scientists can focus on their core tasks without worrying about the intricacies of data serialization or the performance implications of frequent I/O operations. This results in faster development cycles, improved system performance, and more efficient use of computational resources.


## Installation

Install MatDB using pip:

```bash
pip install matdb
```

## Quick Start

```python
from matdb import MatDB

# Initialize the database
db = MatDB('path/to/db')

# Create data
properties={
    'density': 7.8,
    'volume': 22.1
}
structure=Structure.from_spacegroup("Fm-3m", Lattice.cubic(4.1437), ["Cs", "Cl"], [[0, 0, 0], [0.5, 0.5, 0.5]])
data={'structure': structure, 'properties': properties}


# Add data to the database
db.add(structure=structure, properties=properties, table_name='materials')

# Read data from the database
materials_table = db.read(table_name='materials')
print(materials_table.to_pandas())
```

## Usage

### Creating a Database

Initialize a MatDB instance by specifying the path to the database directory:

```python
from matdb import MatDB

db = MatDB('path/to/db')
```

### 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

properties={
    'density': 7.8,
    'volume': 22.1
}
data_list = [
    {'structure': Structure.from_spacegroup("Fm-3m", Lattice.cubic(4.1437), ["Cs", "Cl"], [[0, 0, 0], [0.5, 0.5, 0.5]]), 'properties': properties},
    {'structure': Structure.from_spacegroup("Fm-3m", Lattice.cubic(4.1437), ["Cs", "Cl"], [[0, 0, 0], [0.5, 0.5, 0.5]]), 'properties': properties}
]

db.add_many(dadata_listta, table_name='materials')
```

### 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_materials = db.read(table_name='materials')

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

# Read data with filters
from pyarrow import compute as pc

age_filter = pc.field('age') > 30
older_materials = db.read(table_name='materials', 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': 0, 'property_1': 'metal'},
    {'id': 2, 'property_2': 'gas'}
]

db.update(update_data, table_name='materials')
```

### Deleting Data

Delete records from the database by specifying their IDs.

```python
db.delete(ids=[0, 3], table_name='materials')
```


## 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": "matdb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "materials, science, database, python",
    "author": null,
    "author_email": "Logan Lang <lllang@mix.wvu.edu>",
    "download_url": "https://files.pythonhosted.org/packages/f5/ca/eb080d75e7500da8e9b5bfbaf6a82390c2d280157c0668815caee1c4914b/matdb-0.0.10.tar.gz",
    "platform": null,
    "description": "# MatDB\n\nMatDB is a material science database designed to be light weight and portable. It is built on top of Apache Parquet files using PyArrow, which reduces the overhead of serialization and allows for efficient storage and retrieval of complex data types.\n\n## Table of Contents\n\n- [Features](#features)\n- [Why MatDB?](#why-matdb)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Usage](#usage)\n  - [Creating a Database](#creating-a-database)\n  - [Adding Data](#adding-data)\n  - [Reading Data](#reading-data)\n  - [Updating Data](#updating-data)\n  - [Deleting Data](#deleting-data)\n- [API Reference](#api-reference)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- **Simple Interface**: Easy-to-use methods for creating, reading, updating, and deleting data.\n- **High Performance**: Utilizes Apache Parquet and PyArrow for efficient data storage and retrieval.\n- **Supports Complex Data Types**: Handles nested and complex data types without serialization overhead.\n- **Scalable**: Designed to handle large datasets efficiently.\n- **Schema Evolution**: Supports adding new fields and updating schemas seamlessly.\n\n## Roadmap\n\n- Support foriegn keys use\n- Multiprocessing for reading and writing\n- Increase support for nested structures\n\n## Why MatDB?\n\n### The Challenge of Serialization and Deserialization\n\nIn many data processing and machine learning workflows, a significant performance bottleneck occurs during the serialization and deserialization of data. Serialization is the process of converting complex data structures or objects into a format that can be easily stored or transmitted, while deserialization is the reverse process of reconstructing these objects from the serialized format.\n\nThe need for serialization arises when:\n1. Storing data on disk\n2. Transmitting data over a network\n3. Caching data in memory\n\nHowever, serialization and deserialization can be computationally expensive, especially when dealing with large datasets or complex object structures. This process can lead to:\n\n- Increased I/O operations\n- Higher CPU usage\n- Increased memory consumption\n- Longer processing times\n\nThese issues become particularly problematic in machine learning pipelines, where data needs to be frequently loaded, processed, and saved. The overhead of constantly serializing and deserializing data can significantly slow down the entire workflow, affecting both development iteration speed and production performance.\n\n### How Parquet Files Address the Serialization Challenge\n\nApache Parquet files offer a solution to the serialization/deserialization problem by providing:\n\n1. **Columnar Storage Format**: Parquet stores data in a columnar format, which allows for efficient compression and encoding schemes. This format is particularly beneficial for analytical queries that typically involve a subset of columns.\n2. **Schema Preservation**: Parquet files store the schema of the data along with the data itself. This eliminates the need for separate schema definitions and reduces the risk of schema mismatch errors.\n3. **Efficient Encoding**: Parquet uses advanced encoding techniques like dictionary encoding, bit packing, and run length encoding, which can significantly reduce file sizes and improve read performance.\n4. **Predicate Pushdown**: Parquet supports predicate pushdown, allowing queries to skip irrelevant data blocks entirely, further improving query performance.\n5. **Compatibility**: Parquet files are compatible with various big data processing frameworks, making it easier to integrate into existing data pipelines.\n\nBy leveraging these features, ParquetDB eliminates the need for explicit serialization and deserialization of complex data types. Data can be read directly from and written directly to Parquet files, maintaining its structure and allowing for efficient querying and processing.\n\n### The MatDB Advantage\n\nMatDB builds upon the benefits of Parquet files by providing:\n\n1. A simple, database-like interface for working with Parquet files\n2. Efficient storage and retrieval of complex data types\n3. High-performance data operations leveraging PyArrow's computational capabilities\n4. Seamless integration with machine learning pipelines and data processing workflows\n\nBy using MatDB, developers and data scientists can focus on their core tasks without worrying about the intricacies of data serialization or the performance implications of frequent I/O operations. This results in faster development cycles, improved system performance, and more efficient use of computational resources.\n\n\n## Installation\n\nInstall MatDB using pip:\n\n```bash\npip install matdb\n```\n\n## Quick Start\n\n```python\nfrom matdb import MatDB\n\n# Initialize the database\ndb = MatDB('path/to/db')\n\n# Create data\nproperties={\n    'density': 7.8,\n    'volume': 22.1\n}\nstructure=Structure.from_spacegroup(\"Fm-3m\", Lattice.cubic(4.1437), [\"Cs\", \"Cl\"], [[0, 0, 0], [0.5, 0.5, 0.5]])\ndata={'structure': structure, 'properties': properties}\n\n\n# Add data to the database\ndb.add(structure=structure, properties=properties, table_name='materials')\n\n# Read data from the database\nmaterials_table = db.read(table_name='materials')\nprint(materials_table.to_pandas())\n```\n\n## Usage\n\n### Creating a Database\n\nInitialize a MatDB instance by specifying the path to the database directory:\n\n```python\nfrom matdb import MatDB\n\ndb = MatDB('path/to/db')\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\n\nproperties={\n    'density': 7.8,\n    'volume': 22.1\n}\ndata_list = [\n    {'structure': Structure.from_spacegroup(\"Fm-3m\", Lattice.cubic(4.1437), [\"Cs\", \"Cl\"], [[0, 0, 0], [0.5, 0.5, 0.5]]), 'properties': properties},\n    {'structure': Structure.from_spacegroup(\"Fm-3m\", Lattice.cubic(4.1437), [\"Cs\", \"Cl\"], [[0, 0, 0], [0.5, 0.5, 0.5]]), 'properties': properties}\n]\n\ndb.add_many(dadata_listta, table_name='materials')\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_materials = db.read(table_name='materials')\n\n# Read specific columns\nnames = db.read(table_name='materials', columns=['name'])\n\n# Read data with filters\nfrom pyarrow import compute as pc\n\nage_filter = pc.field('age') > 30\nolder_materials = db.read(table_name='materials', 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': 0, 'property_1': 'metal'},\n    {'id': 2, 'property_2': 'gas'}\n]\n\ndb.update(update_data, table_name='materials')\n```\n\n### Deleting Data\n\nDelete records from the database by specifying their IDs.\n\n```python\ndb.delete(ids=[0, 3], table_name='materials')\n```\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  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.",
    "summary": "Welcome to MatDB, a material science database designed to be light weight and portable.",
    "version": "0.0.10",
    "project_urls": {
        "Changelog": "https://github.com/romerogroup/MatDB/CHANGELOG.md",
        "Issues": "https://github.com/romerogroup/MathDB/issues",
        "Repository": "https://github.com/romerogroup/MatDB"
    },
    "split_keywords": [
        "materials",
        " science",
        " database",
        " python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f83c90ed95dc8473c20830cf73f572052a9182948ba16402e5a8640bec09adc8",
                "md5": "fe65ca95346489df58b7f130a5eb8a62",
                "sha256": "44ef2d36b6ab73e29586c59e6f70cb127e037bba1745c7d4b3e269fdb82b5bcb"
            },
            "downloads": -1,
            "filename": "matdb-0.0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fe65ca95346489df58b7f130a5eb8a62",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 14863,
            "upload_time": "2024-10-03T02:06:07",
            "upload_time_iso_8601": "2024-10-03T02:06:07.692323Z",
            "url": "https://files.pythonhosted.org/packages/f8/3c/90ed95dc8473c20830cf73f572052a9182948ba16402e5a8640bec09adc8/matdb-0.0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f5caeb080d75e7500da8e9b5bfbaf6a82390c2d280157c0668815caee1c4914b",
                "md5": "a0be0486eaf171fdcb1b055d97a73fd4",
                "sha256": "b9297f6c6fd0485b60a535e963d05fd0cb39f303900f647ef5eb82c0aa285e58"
            },
            "downloads": -1,
            "filename": "matdb-0.0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "a0be0486eaf171fdcb1b055d97a73fd4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 25016,
            "upload_time": "2024-10-03T02:06:09",
            "upload_time_iso_8601": "2024-10-03T02:06:09.326179Z",
            "url": "https://files.pythonhosted.org/packages/f5/ca/eb080d75e7500da8e9b5bfbaf6a82390c2d280157c0668815caee1c4914b/matdb-0.0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-03 02:06:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "romerogroup",
    "github_project": "MatDB",
    "github_not_found": true,
    "lcname": "matdb"
}
        
Elapsed time: 1.27040s