hana-ml
Python Machine Learning Client for SAP HANA
What it is and what it does
hana-ml is a Python client that bridges data scientists to SAP HANA's in-database machine learning capabilities. It provides a SAP HANA DataFrame abstraction for querying and filtering data without pulling it to the client, plus APIs to PAL (Predictive Analysis Library) and APL (Automated Predictive Library) for training and scoring models directly in the database. The package also includes visualization tools (EDA plots, model reports, Shapley-value explanations), model persistence (save/load/delete in HANA tables), text mining, and spatial/graph analytics.
The package depends on hdbcli for database connectivity and uses pandas, numpy, plotly, and shapely for data manipulation and visualization. It requires an active SAP HANA instance with appropriate security roles and APL version 1905 or higher for full functionality. Typical workflow involves establishing a connection, creating a HANA DataFrame from a table or SQL query, training a model, and predicting on new data—all with computation happening server-side.
Use it for:
- Build classification or regression models on large HANA tables without exporting data to Python for training.
- Perform exploratory data analysis on HANA data with built-in visualization and reporting functions.
- Train and persist machine learning models directly in HANA for low-latency inference in production.
- Analyze text documents stored in HANA using text mining functions like tf_analysis and text classification.
- Develop geospatial or graph-based analytics on data modeled as spatial or network structures in HANA.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Connects Python to SAP HANA to build machine learning models and query data directly in the database using PAL and APL algorithms without moving data to the client.
Yes, if you have SAP HANA infrastructure and need to build ML models on large datasets without data movement. The package is actively maintained, supports modern Python versions, and offers low install friction. However, the SAP DEVELOPER LICENSE AGREEMENT is non-standard and requires review; one known vulnerability (PYSEC-2023-172) should be investigated before production use. Not suitable for standalone Python ML work or non-SAP environments.
Install
hana-ml on PyPI
pip
pip install hana-mluv
uv add hana-mlpoetry
poetry add hana-mlInstalling hana-ml
Before you install
Low install friction with a pure-Python wheel. Active maintenance with a release 17 days ago. Requires SAP HANA server access and appropriate PAL/APL roles; the package itself installs cleanly but is useless without a running HANA instance and proper database permissions.
License in practice
Licensed under SAP DEVELOPER LICENSE AGREEMENT (not an SPDX standard license). License treatment is unclear; review the full license terms before use in production or commercial contexts to confirm compliance with your intended use.
Quickstart
pip install hana-ml
from hana_ml import dataframe
conn = dataframe.ConnectionContext(address="", port=, user="", password="")
df = conn.table('MY_TABLE', schema='MY_SCHEMA')
df_result = df.collect()
Requires active SAP HANA instance with network access, valid credentials, and AFL__SYS_AFL_AFLPAL_EXECUTE role for PAL; APL version 1905 or higher for APL functionality.
Verify before relying
- Exact scope and restrictions of SAP DEVELOPER LICENSE AGREEMENT for commercial or non-SAP environments
- Details of PYSEC-2023-172 vulnerability and whether it affects current version 2.29.26072700
- Whether PAL and APL require separate licensing or are included with SAP HANA subscription
Package facts
| License | SAP DEVELOPER LICENSE AGREEMENT (unclear) |
| Python support | supports the current Python release (>=3.4) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 11 — hdbcli, pydotplus, Deprecated, tqdm, schedule, prettytable, shapely, plotly, numpy, pandas, jinja2 |
| Maintenance | actively maintained — 17 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 125,519/month — #11,810 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | 1 — PYSEC-2023-172 |
Evidence: hana_ml-2.29.26072700-py3-none-any.whl
Keywords: SAP, HANA, machine, learning, intelligent, enterprise, cloud, PAL, APL, client
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
hdbcliA PEP 249-compliant Python database driver for…
unclear · top 5,000 on PyPI
sqlalchemy-hanaProvides a SQLAlchemy dialect that enables you…
permissive · top 15,000 on PyPI
azure-mgmt-hanaonazureProvides a Python client library to manage SAP…
unclear · top 5,000 on PyPI
pyhdbA pure Python client library for connecting to…
permissive · top 15,000 on PyPI
sap-ai-sdk-genAccess generative AI models from SAP AI Core…
unclear · top 15,000 on PyPI
sap-ai-sdk-coreProvides Python client access to SAP AI Core…
unclear · top 15,000 on PyPI
ai-api-client-sdkProvides Python methods and data structures to…
unclear · top 15,000 on PyPI
sap-ai-sdk-baseA Python client library for accessing SAP's AI…
unclear · top 15,000 on PyPI
generative-ai-hub-sdkProvides Python access to generative AI models…
unclear · top 15,000 on PyPI
pyodatapyodata is a Python client library that…
permissive · top 15,000 on PyPI