Metadata-Version: 2.1
Name: dbcw
Version: 0.2
Summary: Database connection wrapper
Home-page: https://github.com/Stefanitsky/dbcw
Author: stefanitsky
Author-email: stefanitsky.mozdor@google.com
License: UNKNOWN
Project-URL: Documentation, https://github.com/Stefanitsky/dbcw/wiki
Project-URL: Say Thanks!, https://saythanks.io/to/Stefanitsky
Project-URL: Source, https://github.com/Stefanitsky/dbcw
Project-URL: Tracker, https://github.com/Stefanitsky/dbcw/issues
Keywords: db database tool wrapper connection connect
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Database :: Front-Ends
Description-Content-Type: text/markdown
Requires-Dist: psycopg2
Requires-Dist: mysql-connector

[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/Stefanitsky)  [![PyPI version](https://badge.fury.io/py/dbcw.svg)](https://badge.fury.io/py/dbcw)
# DBCW

DBCW (Database Connection Wrapper) is a python package that allows you to connect to different types of databases and contains methods for getting the necessary data.

This is a good choice for you if you do not want to deal with queries to the database and you just need basic functionality for getting data.

But if you need to send your own query to the database - this is also possible.

Supported engines:  
        - PostgreSQL  
        - MySQL  

## Installation

Use the package manager [pip](https://pip.pypa.io/en/stable/) to install dbcw.

```bash
pip install dbcw
```

## Usage

#### Import:
```python
from dbcw import DBConnectionWrapper
```

#### PostgreSQL connection
```python
connection = DBConnectionWrapper(
            host='localhost', user='root', password='1234')
```

#### MySQL connection
```python
connection = DBConnectionWrapper(
            engine='mysql', host='localhost', user='root', password='1234')
```

#### Get database list
```python
>>> connection.get_db_list()
['db1', 'db2']    # output example
```

#### Get tables list from the database
```python
>>> connection.get_tables_list('db_name')
[('friends', 'numbers')]    # output example
```

#### Get table data
```python
connection.get_table_data('db_name', 'table_name')
```

#### Get database structure (depends on engine)
```python
connection.get_db_structure('db_name')
```

#### Get table structure (depends on engine)
```python
connection.get_table_structure('db_name', 'table_name')
```

#### Execute custom query
```python
connection.execute_query('SELECT * FROM table;')
```

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

## License
[MIT](https://choosealicense.com/licenses/mit/)

