Skip to main content

Database connection wrapper

Project description

Say Thanks! PyPI version

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 / MariaDB

Documentation

You can run the pydoc module to read the documentation:

python -m pydoc -b

Installation

Use the package manager pip to install dbcw.

pip install dbcw

Usage

Import:

from dbcw import DBConnectionWrapper

PostgreSQL connection

connection = DBConnectionWrapper(
            host='localhost', user='root', password='1234')

MySQL connection

connection = DBConnectionWrapper(
            engine='mysql', host='localhost', user='root', password='1234')

Get database list

>>> connection.get_db_list()
['db1', 'db2']    # output example

Get tables list from the database

>>> connection.get_tables_list('db_name')
[('friends', 'numbers')]    # output example

Get table data

connection.get_table_data('db_name', 'table_name')

Get database structure (depends on engine)

connection.get_db_structure('db_name')

Get table structure (depends on engine)

connection.get_table_structure('db_name', 'table_name')

Execute custom query

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dbcw, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size dbcw-0.2.2-py3-none-any.whl (8.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size dbcw-0.2.2.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page