retrieve data from centralSystem.org
Project description
simplify data retrieving on centralSystem.org
download file
import central50
from central50 import Client, ApiRequest, Method
c = Client(data_endpoint="",access_key="", secret_key="",authorized_endpoint="")
api_request = ApiRequest(data_address="1754C67BE4821000", request_path="api-provider/download/local/123456",
method=Method.POST)
try:
# 模式一
r = c.call_api(api_request)
with open('./img8.jpg', 'wb') as f:
f.write(r.content)
# 模式二
f = open('./img5.jpg', 'wb')
response_stream = c.call_api_stream(api_request)
with response_stream as r:
for chunk in r.iter_bytes(chunk_size=4096):
f.write(chunk)
finally:
f.close()
do http
import central50
from central50 import Client, ApiRequest, Method
c = Client(data_endpoint="",access_key="", secret_key="",authorized_endpoint="")
params = {'pkey1': 'value1', 'pkey2': 'value2'}
json = {'jkey1': 'value1', 'jkey2': 'value2'}
headers = {'user-agent': 'my-app/0.0.1'}
api_request = ApiRequest(data_address="178589E198821000", request_path="post",
method=Method.POST, headers=headers, params=params, json=json, timeout=10)
response = c.call_api(api_request)
print(response.content)
do pgsql
import central50
from central50 import Client, ApiRequest, Method
c = Client(data_endpoint="",access_key="", secret_key="",authorized_endpoint="")
json = {"payload": "{ \"sql\": \"select * from zs.student\" }"}
api_request = ApiRequest(data_address="1785CB2070C21000", request_path="pg",
method=Method.POST, json=json, timeout=10)
response = c.call_api(api_request)
print(response.content)
do odps
import logging
import central50
from central50 import Client, ApiRequest, Method
c = Client(data_endpoint="",access_key="", secret_key="",authorized_endpoint="")
json = {"payload": "{ \"selectSql\": \"select * from user \" }"}
api_request = ApiRequest(data_address="174FB94000C21000", request_path="get/odps",
method=Method.POST, json=json, timeout=10)
response = c.call_api(api_request)
print(response.content)
enable log
import logging
import central50
central50.set_file_logger("../log/central.log", level=logging.DEBUG)
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
central50-1.0.1.tar.gz
(5.3 kB
view details)
Built Distribution
File details
Details for the file central50-1.0.1.tar.gz
.
File metadata
- Download URL: central50-1.0.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cce0525b4b34447928e132050542b4d1ccacedfe2077b51d60ef6437f8d6017 |
|
MD5 | 80603109cffb30883e7209c2ea7bf201 |
|
BLAKE2b-256 | dccf261cd018edd700aeac21ec84d457749080288707671666a4a7385cdec484 |
File details
Details for the file central50-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: central50-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5731b064c90714ebff3f90b15a63589fc3cb62a49590df7274dadc85c2076659 |
|
MD5 | 5a720f6fbe086294166163a525cac37c |
|
BLAKE2b-256 | 00ba342854d7a91dc2028845e921df71ba12eaae2c30b028753a2d38f051cfb0 |