Skip to content

Hana

HANA reader.

koheesio.spark.readers.hana.HanaReader #

Wrapper around JdbcReader for SAP HANA

Notes
Example

Note: jars should be added to the Spark session manually. This class does not take care of that.

This example depends on the SAP HANA ngdbc JAR. e.g. ngdbc-2.5.49.

from koheesio.spark.readers.hana import HanaReader

jdbc_hana = HanaReader(
    url="jdbc:sap://<domain_or_ip>:<port>/?<options>",
    user="YOUR_USERNAME",
    password="***",
    dbtable="schema_name.table_name",
)
df = jdbc_hana.read()

Parameters:

Name Type Description Default
url str

JDBC connection string. Refer to SAP HANA docs for the list of all available connection string parameters. Example: jdbc:sap://:[/?]

required
user str
required
password SecretStr
required
dbtable str

Database table name, also include schema name

required
options Optional[Dict[str, Any]]

Extra options to pass to the SAP HANA JDBC driver. Refer to SAP HANA docs for the list of all available connection string parameters. Example: {"fetchsize": 2000, "numPartitions": 10}

required
query Optional[str]

Query

required
format str

The type of format to load. Defaults to 'jdbc'. Should not be changed.

required
driver str

Driver name. Be aware that the driver jar needs to be passed to the task. Should not be changed.

required

driver class-attribute instance-attribute #

driver: str = Field(
    default="com.sap.db.jdbc.Driver",
    description="Make sure that the necessary JARs are available in the cluster: ngdbc-2-x.x.x.x",
)

options class-attribute instance-attribute #

options: Optional[Dict[str, Any]] = Field(
    default={"fetchsize": 2000, "numPartitions": 10},
    description="Extra options to pass to the SAP HANA JDBC driver",
)