Citybrain Platform Python Library
The Citybrain Platform Python Library provides convenient access to the Citybrain Platform API from applications written in the Python language.
installation
If you just want to use the package, just run:
pip install --upgrade citybrain-platform
Usage
The library needs to be configured with your account's secret key which is available on www.citybrain.org. Either set it as the CITYBRAIN_APIKEY environment variable before using the library:
export CITYBRAIN_APIKEY='...'
Or set citybrain_platform.api_key to its value:
import citybrain_platform
citybrain_platform.api_key = "..."
Example Code
Examples of how to use this Python library to accomplish various tasks.
Table Operations
Create Table
import citybrain_platform
from citybrain_platform.computing.data_types import Column, ColumnType
columns = [
Column("col_str", ColumnType.STRING, "this is a comment"),
Column("col_id", ColumnType.BIGINT),
]
partition_columns = [
Column("col_pt", ColumnType.INT, "a column for partitioning")
]
ok = citybrain_platform.Computing.create_table(name="test_tbl", columns=columns, partition_columns=partition_columns)
print(ok)
Get Table Schema
import citybrain_platform
schema = citybrain_platform.Computing.get_table_schema(name="test_tbl")
print(schema)
Upload Table Data
import citybrain_platform
result = citybrain_platform.Computing.upload_table_data(name="test_tbl", append=True, csv_filepath="aa.csv", partition_key={"col_pt": "19"})
print(result)
Truncate Table
import citybrain_platform
result = citybrain_platform.Computing.truncate_table(name="test_tbl", partition_key={"col_pt": "19"})
print(result)
Drop Table
import citybrain_platform
result = citybrain_platform.Computing.drop_table(name="test_tbl")
print(result)
Make Table Public To Others
import citybrain_platform
public_table_name = citybrain_platform.Computing.public_table(name="test_tbl")
print(public_table_name)
List Available Tables
import citybrain_platform
tables = citybrain_platform.Computing.list_tables()
print(tables)
Job Operations
Create Job
import citybrain_platform
job_id = citybrain_platform.Computing.create_job(sql="select col_str from test_tbl limit 12;")
print(job_id)
Get Job Status
import citybrain_platform
job_status = citybrain_platform.Computing.get_job_status(job_id="...")
print(job_status)
Stop Running Job
import citybrain_platform
result = citybrain_platform.Computing.stop_job(job_id="...")
print(result)
Download Terminated Job Results
import citybrain_platform
citybrain_platform.Computing.get_job_results(job_id="...", filepath="results.csv")
Metadata
Release files for jump2odps 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jump2odps-0.0.1.tar.gz | 4.9 kB | Without provenance | Details for jump2odps-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jump2odps-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for jump2odps-0.0.1-py3-none-any.whl |
Total release size: 11.3 kB
Release files / jump2odps-0.0.1.tar.gz
| Download URL | jump2odps-0.0.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9776282124987e2b2aab37382367071c0cc3dcf45aa6a3d2d1d3a3fe38a7d222
|
|
BLAKE2b-256 checksum How to use checksums |
1585f0f7cbe720ea9f8fdfe639672126c1e7fb86aec9941c75e3baac8cd14715
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.10
|
Release files / jump2odps-0.0.1-py3-none-any.whl
| Download URL | jump2odps-0.0.1-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c094780434eb306d94e569f0cd2592807d14750b1dc46a2d35683bac249ab43
|
|
BLAKE2b-256 checksum How to use checksums |
fade794f179f1b8f93115870e8f0aae0f46aa97d92d2105b332b59fc9e1ec635
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.10
|
Security for jump2odps 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.