Skip to main content

Power your data connections with python and queries with dconnect

Project description

dconnect

Power your data connections with python and query with dconnect

dconnect is a lightweight data source connector wrapper for different databases, User can also perfom queries and will get data.

Available datasources campactibility:

SQLite, MySQL, SQL Server, Azure SQL, PostgreSQL, Redshift, Snowflake, Clickhouse, Oracle, IBM_Db, Vertica, MongoDB, AWS S3 Bucket, GoogleSheets, Elasticsearch, Google Analytics, Neo4j

Installation

Installation from Git

Clone repository using below command

git clone https://github.com/nit567esh/dconnect.git

Go to python package folder and use below command to install the package into library location:

$ cd <pkg_directory>
$ python3 setup.py install

Installation from Pypi

Install directly from Pypi using below command

pip install dconnect 
or
python3 -m pip install dconnect

Usages

In order to use the dcoonect, use below steps

  1. Download credentails.json file.
  2. Configure the required connection using the credentails.json template.
  3. Store it somewhere in safe folder.
  4. Use below commands to run you dconnect
>>> import dconnect as c
>>> conids = c.conids('path_of_your_saved_credentails.json')
>>> print(conids) # Choose any connection id from list to validate the connection
>>> con = c.connect('your_connection_id(dsidentifier key in credentails.json)')
>>> df  = c.runsql(con, 'show tables;')

Functions:

  1. List configured connection IDs
>>> import dconnect as c
>>> conids = c.conids('path_of_your_saved_credentails.json')
>>> print(conids)
  1. Connect using a conid
>>> con = c.connect('<your_connection_id>')
  1. You can only run SQL queries incase on Relational DBs/DWs connection object.
>>> df = c.runsql(con,'<Sql-Query>')

Examples:

1. For Relational DBs/DWs

>>> con = c.connect('redshift_<host>_<database>')
>>> df = c.runsql(con,'select top 10 * from edw.dim_product')

Note - Same is applicalble for the following list of DBs: SQLite, MySQL, SQL Server, Azure SQL, PostgreSQL, Redshift, Snowflake, Clickhouse, Oracle, IBM_Db, Vertica

2. For Others Function runsql is only applicable to relational DBs/DWs. For other data source dconnect only allow to connect with data source and for query purpose you can ues the respective generic packages using the connection object initilized by dconnect.

Google Sheet Example

>>> con = c.connect('gsheet_<username>@gamil.com') # using dconnect
>>> sh = con.open("<GsheetName>") # using pysgsheets
>>> wks = sh.worksheet_by_title("<GsheetTab>")  # using pysgsheets
>>> df = wks.get_as_df()  # using pysgsheets
DataSource Pythob Pkg GitRepo Pypi Dependencies
Google Sheet pygsheets https://github.com/nithinmurali/pygsheets https://pygsheets.readthedocs.io/en/stable/ client_secret json file
Google Analytics google2pandas https://github.com/panalysis/Google2Pandas https://pypi.org/project/Google2Pandas/ client_secret json file, token file
GoogleAds googleads https://github.com/googleads/googleads-python-lib https://pypi.org/project/googleads/ client_secret json file
AWS S3 boto3 https://github.com/boto/boto3 https://pypi.org/project/boto3/
Mongo DB pymongo https://github.com/mher/pymongo https://pypi.org/project/pymongo/
Elasticsearch elasticsearch https://github.com/elastic/elasticsearch https://pypi.org/project/elasticsearch/
Neo4j neo4j https://github.com/neo4j https://pypi.org/project/neo4j/

Todos

  • REST API, FTP, SFTP, Google Adsense/Manager/Search Console, Mixpanel, Hive, HDFC, Apache Kylin, Apache Druid and many more

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

dconnect-0.0.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file dconnect-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: dconnect-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.4

File hashes

Hashes for dconnect-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e73d057b208169ccbd8b514e70beb8eaf406948e0440853ae9696070b37f76ea
MD5 32b46545b021d85f4675c051f9d8da11
BLAKE2b-256 06b633927de7f164672980dddeae1a3c593898583c31403859a877e0b122531f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page