Metadata-Version: 2.1
Name: dbsys
Version: 0.1.8
Summary: A library for managing database operations using SQLAlchemy and pandas
Home-page: https://github.com/lifsys/dbsys
Author: Mark Powers
Author-email: mpoweru@lifsys.com
Project-URL: Bug Tracker, https://github.com/lifsys/dbsys/issues
Project-URL: Documentation, https://github.com/lifsys/dbsys/blob/main/README.md
Project-URL: Source Code, https://github.com/lifsys/dbsys
Keywords: database sqlalchemy pandas orm data management
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=1.0.0
Requires-Dist: sqlalchemy>=1.3.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=3.0; extra == "dev"
Requires-Dist: flake8>=4.0; extra == "dev"
Requires-Dist: black>=22.0; extra == "dev"
Requires-Dist: mypy>=0.900; extra == "dev"
Requires-Dist: isort>=5.0; extra == "dev"

# dbsys

dbsys is a Python library for managing database operations using SQLAlchemy and pandas. It provides a high-level interface for common database operations, including reading, writing, creating tables, deleting tables, deleting columns, and deleting rows.

[![PyPI version](https://badge.fury.io/py/dbsys.svg)](https://badge.fury.io/py/dbsys)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Installation

You can install the latest version of dbsys using pip:

```
pip install --upgrade dbsys
```

For a specific version:

```
pip install dbsys==0.1.8
```

## Installation

You can install dbsys using pip:

```
pip install dbsys
```

For development purposes, you can install the package with extra dependencies:

```
pip install dbsys[dev]
```

This will install additional packages useful for development, such as pytest, flake8, and mypy.

## Features

- Read entire tables
- Write data to tables
- Create new tables
- Delete tables
- Delete specific columns
- Delete specific rows

## Usage

Here's a quick example of how to use dbsys:

```python
from dbsys import manage_db
import pandas as pd

# Create a sample DataFrame
data = pd.DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'c']})

# Database URL
db_url = "sqlite:///example.db"

# Create a new table
manage_db(db_url, "my_table", "c", data)

# Read the table
result = manage_db(db_url, "my_table", "r")
print(result)

# Delete a column
manage_db(db_url, "my_table", "dc", column_name="B")

# Delete a row
manage_db(db_url, "my_table", "dr", row_identifier={"A": 2})

# Delete the table
manage_db(db_url, "my_table", "dt")
```

## API Reference

### `manage_db(database_url: str, table_name: str, operation: str, data: Optional[pd.DataFrame] = None, column_name: Optional[str] = None, row_identifier: Optional[Dict[str, Any]] = None) -> Optional[pd.DataFrame]`

Manage database tables using pandas dataframes and SQLAlchemy.

Parameters:
- `database_url` (str): URL of the database to connect to.
- `table_name` (str): Name of the table to operate on.
- `operation` (str): Operation to perform. Valid options are:
  - 'r' or 'read': Read the entire table.
  - 'w' or 'write': Write data to the table, replacing existing data.
  - 'c' or 'create': Create a new table with the provided data.
  - 'dt' or 'delete table': Delete the entire table.
  - 'dc' or 'delete column': Delete a specific column from the table.
  - 'dr' or 'delete row': Delete a specific row from the table.
- `data` (Optional[pd.DataFrame]): DataFrame to write or create table with. Required for 'w' and 'c' operations.
- `column_name` (Optional[str]): Name of the column to delete. Required for 'dc' operation.
- `row_identifier` (Optional[Dict[str, Any]]): Dictionary containing column:value pair to identify the row to delete. Required for 'dr' operation.

Returns:
- Optional[pd.DataFrame]: DataFrame representing the current state of the table after the operation, or None for delete operations.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

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

## Support

If you encounter any problems or have any questions, please [open an issue](https://github.com/lifsys/dbsys/issues) on our GitHub repository.

## Changelog

### 0.1.8
- Prepared for PyPI update
- Updated documentation
- Added support for Python 3.12

### 0.1.7
- Minor code improvements and documentation updates
- Prepared for PyPI update

### 0.1.6
- Added DatabaseManager to __init__ and __all__ lists
## About Lifsys, Inc

Lifsys, Inc is an AI company dedicated to developing solutions for the future. For more information, visit [www.lifsys.com](https://www.lifsys.com).
