datus-odps
ODPS (MaxCompute) database adapter for Datus.
Installation
pip install datus-odps
This will automatically install the required dependencies:
datus-agentpyodpspandaspyarrow
Usage
The adapter is automatically registered with Datus when installed. Configure your database connection in your Datus configuration:
database:
type: odps
access_id: your_access_key_id
access_key: your_access_key_secret
project: your_project_name
endpoint: https://service.cn-shanghai.maxcompute.aliyun.com/api
Or use programmatically:
from datus_odps import ODPSConnector, ODPSConfig
# Create connector with config object
config = ODPSConfig(
access_id="your_access_key_id",
access_key="your_access_key_secret",
project="your_project_name",
endpoint="https://service.cn-shanghai.maxcompute.aliyun.com/api"
)
connector = ODPSConnector(config=config)
# Or create connector with dict
connector = ODPSConnector(config={
"access_id": "your_access_key_id",
"access_key": "your_access_key_secret",
"project": "your_project_name",
"endpoint": "https://service.cn-shanghai.maxcompute.aliyun.com/api"
})
# Test connection
connector.test_connection()
# Execute query
result = connector.execute_query("SELECT * FROM your_table LIMIT 10")
print(result.sql_return)
# Get table list
tables = connector.get_tables()
print(f"Tables: {tables}")
# Get table schema
schema = connector.get_schema(table_name="your_table")
for column in schema:
print(f"{column['name']}: {column['type']}")
# Get tables with DDL
tables_with_ddl = connector.get_tables_with_ddl()
for table_info in tables_with_ddl:
print(f"Table: {table_info['table_name']}")
print(f"DDL: {table_info['definition']}")
# Get sample rows
samples = connector.get_sample_rows(tables=["your_table"], top_n=5)
for sample in samples:
print(f"Sample from {sample['table_name']}:")
print(sample['sample_rows'])
Configuration Options
The ODPSConfig class supports the following parameters:
access_id(required): Aliyun Access Key IDaccess_key(required): Aliyun Access Key Secretproject(required): ODPS project nameendpoint(required): ODPS service endpoint (e.g.,https://service.cn-shanghai.maxcompute.aliyun.com/api)timeout_seconds(optional): Connection timeout in seconds (default: 30)use_sqa(optional): Whether to use SQA (SQL Query Acceleration)quota_name(optional): Quota name for resource management
Features
- Full CRUD operations (SELECT, INSERT, UPDATE, DELETE)
- DDL execution (CREATE, ALTER, DROP)
- Metadata retrieval (tables, schemas)
- Sample data extraction
- Multiple result formats (pandas, arrow, csv, list)
- Connection management
- Comprehensive error handling
- Project-based namespace support (ODPS uses projects as databases)
ODPS-Specific Notes
- Project as Database: ODPS uses projects as the main namespace (similar to databases in traditional SQL databases)
- Table Naming: Tables are referenced as
project.table_name - Schemas: ODPS may support schemas in newer versions, but typically uses projects as the main namespace
- SQL Execution: All SQL queries are executed through PyODPS SDK
Requirements
- Python >= 3.12
- ODPS (MaxCompute) account with valid Access Key credentials
- datus-agent >= 0.2.1
- pyodps >= 0.11.0
- pandas >= 2.0.0
- pyarrow >= 10.0.0
License
Apache License 2.0
Metadata
Release files for datus-odps 0.1.0
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 |
|---|---|---|---|---|
| datus_odps-0.1.0.tar.gz | 16.6 kB | Without provenance | Details for datus_odps-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| datus_odps-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for datus_odps-0.1.0-py3-none-any.whl |
Total release size: 26.4 kB
Release files / datus_odps-0.1.0.tar.gz
| Download URL | datus_odps-0.1.0.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac0144d069917f2ea59f6110155503c6963f22ef3adf5d6797d34b8ad4d83390
|
|
BLAKE2b-256 checksum How to use checksums |
5e7299b13c16efd3de125e520ac14cd5333ed4e792a1d7c44bdb1321008acf2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.6
|
Release files / datus_odps-0.1.0-py3-none-any.whl
| Download URL | datus_odps-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e10504d33a7e9b6b7ce346b5f35508180f9e6a5ee87264bc36cd9e2c0cbba6a7
|
|
BLAKE2b-256 checksum How to use checksums |
cb39c9b31a04de4ac7b728de8027416b5e7665925c6f682448d529df98771b56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.6
|
Security for datus-odps 0.1.0
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.