For AFS developer to access Datasource
Project description
AFS2-DataSource SDK
The AFS2-DataSource SDK package allows developers to easily access PostgreSQL, MongoDB, InfluxDB.
Installation
Support Pyton version 3.6 or later
pip install afs2-datasource
Example
Database config
Database config from environment variable.
Export database config on command line.
export PAI_DATA_DIR="{"type": "mongo-firehose","data": {"dbType": "internal","querySql": "{QUERY_STRING}","collection": "{COLLECTION_NAME}","credential": {"username": "{DB_USERNAME}","password": "{DB_PASSWORD}","database": "{DB_NAME}","port": {DB_PORT},"host": "{DB_HOST}"}}}"
Export database config via Python
os.environ['PAI_DATA_DIR'] = {
"type": "mongo-firehose",
"data": {
"dbType": "internal",
"querySql": "{QUERY_STRING}",
"collection": "{COLLECTION_NAME}",
"credential": {
"username": "{DB_USERNAME}",
"password": "{DB_PASSWORD}",
"database": "{DB_NAME}",
"port": {DB_PORT},
"host": "{DB_HOST}"
}
}
}
DBManager Example
from afs2datasource import DBManager
# Init DBManager
manager = DBManager()
# Connect DB
manager.connect()
# Execute querySql in DB config
data = manager.execute_query()
# Return type: DataFrame
"""
Age Cabin Embarked Fare ... Sex Survived Ticket_info Title2
0 22.0 7.0 2.0 7.2500 ... 1.0 0.0 2.0 2.0
1 38.0 2.0 0.0 71.2833 ... 0.0 1.0 14.0 3.0
2 26.0 7.0 2.0 7.9250 ... 0.0 1.0 31.0 1.0
3 35.0 2.0 2.0 53.1000 ... 0.0 1.0 36.0 3.0
4 35.0 7.0 2.0 8.0500 ... 1.0 0.0 36.0 2.0
...
"""
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file afs2-datasource-2.1.14.tar.gz.
File metadata
- Download URL: afs2-datasource-2.1.14.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
401282578cfe13779bf0af87e9dfc2150dfb91c679d64aa903563a79dc6ab2f4
|
|
| MD5 |
84bff330c79f4bc7d6de53a9de469cdd
|
|
| BLAKE2b-256 |
783d8a9958823a4494af8b9ed9d942234deff7f6625904e0003d6deb753b443f
|
File details
Details for the file afs2_datasource-2.1.14-py3-none-any.whl.
File metadata
- Download URL: afs2_datasource-2.1.14-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
706f9ebfbfb95d09889f8681ce4cca8caeb1872c9256ef3d638c2218a9ef6aba
|
|
| MD5 |
2de1a63cb48b8582788138b2882ae7d5
|
|
| BLAKE2b-256 |
24cee665536369f465c931ee2c7f24062211c3281b7bb9c22f3fac7848867814
|