Python Examples for Querying through JDBC/ODBC

Using Ascend's JDBC / ODBC Connection, developers can query Ascend directly from Python scripts. While File-Based Access is a high-throughput option for retrieving all of a component's records, this interface enables developers to execute a query from a script to retrieve a subset of the records they are interested in. The query executes in Ascend, which helps to decrease processing requirements of the client.

Python scripts connect to Ascend through their choice of JDBC or ODBC:

  • JDBC requires a Java runtime, requires the Apache-licensed Hive Driver
  • ODBC does not require Java, requires a license for the Simba Spark ODBC Driver

Python Script with JDBC Connection

Prerequisites:

Follow the below "Recipe" for sample code that creates a connection and runs a query.

Python Script with ODBC Connection

Prerequisites:

Follow the below "Recipe" for sample code that creates a connection and runs a query.


Did this page help you?