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
- Download credentails.json file.
- Configure the required connection using the credentails.json template.
- Store it somewhere in safe folder.
- 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:
- List configured connection IDs
>>> import dconnect as c
>>> conids = c.conids('path_of_your_saved_credentails.json')
>>> print(conids)
- Connect using a conid
>>> con = c.connect('<your_connection_id>')
- 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
Built Distribution
File details
Details for the file dconnect-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: dconnect-1.0.0-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f3bb9df35f009a8f5e01c3e40d82c9c9769e08dd63373fea91dc3982fd4a180 |
|
MD5 | df5b0bda639b0932d8a7cd3b9f3c2566 |
|
BLAKE2b-256 | 14c513abd8114aa14fa75b6826b216e1386dc6f02bf86ee7d7338effc4a6f8f9 |