Skip to main content

ODPS (MaxCompute) database adapter for Datus

Project description

datus-odps

ODPS (MaxCompute) database adapter for Datus.

Installation

pip install datus-odps

This will automatically install the required dependencies:

  • datus-agent
  • pyodps
  • pandas
  • pyarrow

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 ID
  • access_key (required): Aliyun Access Key Secret
  • project (required): ODPS project name
  • endpoint (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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datus_odps-0.1.0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datus_odps-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file datus_odps-0.1.0.tar.gz.

File metadata

  • Download URL: datus_odps-0.1.0.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for datus_odps-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ac0144d069917f2ea59f6110155503c6963f22ef3adf5d6797d34b8ad4d83390
MD5 2ba9eda254d40a06fb70f8794e111f88
BLAKE2b-256 5e7299b13c16efd3de125e520ac14cd5333ed4e792a1d7c44bdb1321008acf2d

See more details on using hashes here.

File details

Details for the file datus_odps-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for datus_odps-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e10504d33a7e9b6b7ce346b5f35508180f9e6a5ee87264bc36cd9e2c0cbba6a7
MD5 64b258ef157db39e849204ab4909b7a7
BLAKE2b-256 cb39c9b31a04de4ac7b728de8027416b5e7665925c6f682448d529df98771b56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page