convez.ai
MCP ServerDados & AnalyticsIntermediário
bug-ops

pyhdb-rs: Driver SAP HANA em Rust com Arrow & MCP

bug-ops/pyhdb-rs

Conecte SAP HANA a workflows Python/IA com streaming Arrow sem cópias

Ver no GitHub
BomPluginScore · de 0 a 100

Driver Rust puro para SAP HANA sem dependências SAP nativas, com suporte zero-copy para Apache Arrow, Polars e pandas. Inclui servidor MCP para assistentes de IA explorar schemas HANA com segurança e acesso programático otimizado. Elimina instalação de cliente SAP e overhead de serialização em pipelines analíticos.

Instalação

$npx convez-ai bug-ops/pyhdb-rs

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
4
Forks
1
Acompanhando
1
Saúde
85%
Último commit
há 3 dias
Versão
v0.5.0
Issues abertas
2
Contribuidores
2

Casos de uso

  • Exportar dados SAP HANA para Polars/pandas sem instalação de cliente
  • Pipelines ETL de alto desempenho com zero-copy Arrow streaming
  • Assistentes de IA (Claude/Cline) descobrir e consultar schemas HANA via MCP

Veredito

Solução sólida que resolve um pain point real: acesso modern pythônico ao SAP HANA sem complexidade de clientes nativos. O suporte a Arrow e MCP integra bem com o ecossistema de IA. Caso de uso claro para data engineers em empresas SAP.

README

A tradução para o português deste README ainda está na fila.

pyhdb-rs

Unlock your SAP HANA data for modern analytics and AI workflows.

Pure Rust toolkit — no SAP client installation required. Connect to HANA from anywhere, stream data directly into Polars, pandas, or DuckDB via Apache Arrow. Let AI assistants explore your schemas through a secure MCP interface.

CI Security codecov CodSpeed PyPI Crates.io License

Why pyhdb-rs?

Pain PointSolution
SAP client installation & licensingPure Rust — no SAP dependencies, just pip install
Memory explodes with big datasetsZero-copy Arrow streams data directly to DataFrames
Manual schema discovery for AI toolsMCP server gives Claude/Cline native HANA access
Complex ETL for analyticsOne-liner to Polars LazyFrame or pandas

Quick Start

For Data Engineers & Scientists

pip install pyhdb_rs
from pyhdb_rs import ConnectionBuilder
import polars as pl

# Connect and extract — data flows directly to Polars without copies
conn = ConnectionBuilder.from_url("hdbsql://user:pass@hana:30015").build()
df = pl.from_arrow(conn.execute_arrow("""
    SELECT material, plant, SUM(quantity) as total
    FROM sapabap1.mard
    GROUP BY material, plant
"""))

# Lazy evaluation for memory-efficient analytics
result = df.lazy().filter(pl.col("total") > 1000).collect()

[!TIP] Data exports via Apache Arrow — the universal columnar format. Integrates with the entire Arrow ecosystem out of the box.

Arrow Ecosystem Compatibility

Stream HANA data directly into any Arrow-compatible tool:

CategoryTools
DataFramesPolars, pandas, Vaex, Dask
Query EnginesDuckDB, DataFusion, ClickHouse
ETL / StreamingApache Spark, Apache Flink, Kafka + Arrow
ML / AIRay, Hugging Face Datasets, PyTorch
Data LakesDelta Lake, Apache Iceberg, Lance
SerializationParquet, Arrow IPC/Feather

Zero-copy data transfer means no serialization overhead between HANA and your analytics stack.

For AI-Assisted Development

cargo install hdbconnect-mcp

Add to Claude Desktop config:

{
  "mcpServers": {
    "hana": {
      "command": "hdbconnect-mcp",
      "args": ["--url", "hdbsql://user:pass@hana:30015"]
    }
  }
}

Now ask Claude: "Show me the top 10 customers by revenue from VBAK/VBAP" — it queries HANA directly.

Components

PackageUse CaseInstall
pyhdb_rsPython analytics, ETL pipelines, ML feature extractionpip install pyhdb_rs
hdbconnect-mcpAI assistants, natural language queries, schema explorationcargo install hdbconnect-mcp
hdbconnect-arrowRust applications, custom Arrow integrationscargo add hdbconnect-arrow

Python Driver

Full DB-API 2.0 compliance with native Arrow integration. No SAP client required — works anywhere Python runs.

from pyhdb_rs.aio import ConnectionPoolBuilder
import polars as pl

pool = ConnectionPoolBuilder().url("hdbsql://user:pass@hana:30015").max_size(10).build()

async def extract_sales(region: str) -> pl.DataFrame:
    async with pool.acquire() as conn:
        return pl.from_arrow(await conn.execute_arrow(f"""
            SELECT vbeln, erdat, netwr FROM sapabap1.vbak
            WHERE region = '{region}' AND erdat >= '20240101'
        """))

# Parallel extraction across regions
results = await asyncio.gather(*[extract_sales(r) for r in ["US", "EU", "APAC"]])
import pyarrow as pa

reader = conn.execute_arrow("SELECT * FROM sapabap1.mara WHERE mtart = 'FERT'")
df = pa.RecordBatchReader.from_stream(reader).read_all().to_pandas()
from pyhdb_rs import ArrowConfig

# Process 100M rows with constant memory
config = ArrowConfig(batch_size=50_000)
reader = conn.execute_arrow("SELECT * FROM sapabap1.mseg", config=config)

for batch in reader:
    process_batch(batch)  # Each batch: 50K rows as Arrow RecordBatch

Full documentation: Python package README — TLS configuration, HA clusters, transaction control, error handling.

MCP Server for AI Agents

Production-ready server that exposes SAP HANA to Claude, Cline, Cursor, and any MCP-compatible assistant.

Why it matters: Instead of copy-pasting schemas or writing boilerplate queries, let AI discover and query your data directly — with guardrails.

Security by design:

  • Read-only mode blocks DML/DDL by default
  • Row limits prevent data exfiltration
  • OIDC/JWT authentication for enterprise deployments
  • Per-user cache isolation in multi-tenant setups

Available tools:

ToolWhat AI can do
list_tablesExplore schemas: "What tables exist in SAPABAP1?"
describe_tableUnderstand structure: "Show me VBAK columns"
execute_sqlQuery data: "Get top customers by revenue"
pingVerify connectivity

Full documentation: MCP server README — HTTP transport, Kubernetes deployment, Prometheus metrics.

Architecture

flowchart TB
    subgraph apps["Your Applications"]
        direction LR
        subgraph python["Python Analytics"]
            p1["ETL Pipelines"]
            p2["ML Features"]
            p3["BI Dashboards"]
        end
        subgraph ai["AI Assistants"]
            m1["Claude Desktop"]
            m2["Cline / Cursor"]
            m3["Custom Agents"]
        end
    end

    subgraph core["Rust Core"]
        arrow["hdbconnect-arrow\nZero-copy HANA → Arrow"]
    end

    subgraph hana["SAP HANA"]
        db[("BW/4HANA\nS/4HANA\nHANA Cloud")]
    end

    apps --> core
    core --> hana

    style apps fill:#e3f2fd
    style core fill:#fff8e1
    style hana fill:#e8f5e9

Requirements

  • Python 3.12+ (for pyhdb_rs)
  • Rust 1.88+ (for building from source or MCP server)

Resources

ResourceLink
Python APIpython/README.md
MCP Servercrates/hdbconnect-mcp/README.md
Arrow Integrationcrates/hdbconnect-arrow/README.md
ChangelogCHANGELOG.md
ContributingCONTRIBUTING.md

License

Dual-licensed under Apache-2.0 or MIT at your option.

Ver o original no GitHub

Bom para

Relacionados