Use Python Sybase Driver to Connect to SAP ASE in SAP HANA Cloud
- How to create an interfaces file
- How to connect to an instance using Python Sybase Driver
- How to verify the connection to an SAP ASE instance in SAP HANA Cloud
- You need to have a running SAP HANA Cloud, SAP ASE instance.
- You require a Linux OS to follow the instructions in this tutorial.
In this tutorial group, you will learn how to connect to your SAP HANA Cloud, SAP Adaptive Server Enterprise database.
There are a few tools you can use to access and connect to the database. With these programming interfaces and drivers, you can then query and manipulate the data available there.
In each tutorial of this tutorial group, you can learn how to connect using a different interface or driver:
- Step 1
Before you can connect to any SAP HANA Cloud, SAP ASE instance, you need to make sure the instance is running in SAP HANA Cloud Central.
Then, you need to make sure you have the SAP HANA Cloud, SAP ASE Client SDK drivers are installed in a Linux system. To learn more about this, check out our technical documentation. There you will find a description and the link to download the SDK.
Then, to set up a connection, you will need the SQL Endpoint of the instance. To get it, follow these steps:
In SAP HANA Cloud Central, click on the three dots button on the right side of the row for your SAP ASE instance.
In the drop-down menu, select SQL Endpoint. This is the host name that you need to enter in the interfaces file to connect with your client.
Now that your preparations are done, you can get started.
In the coming steps, learn how to connect using the Python Sybase Driver.
You can either follow the steps below or watch this video:
- Step 2
To connect to a running SAP ASE database in SAP HANA Cloud using the Python Sybase Driver, follow these steps:
Download and install the Python Sybase Driver from here.
First, open a PuTTy session and go to the Sybase directory.
The Python Sybase Driver uses an interface file, so you need to make sure there is an entry in the interfaces file for this ASE instance that you want to connect to.
Open your text editor, in this example, you will see the Vi text editor:Shell/BashCopy
Enter the name of the instance you want to connect to.
Under it, add a query line following this structure:Shell/BashCopy
query tcp ether <SQL Endpoint> <Port number> ssl="CN=hanacloud.ondemand.com"
Delete the colon between the server and the port number of your SQL Endpoint and insert a space in between. Here is an example:
query tcp ether 1a1a1a1a-2b2b-3c3c-4d4d-5e5e5e5e5e5e.ase.hxtp.xxxxxxxxxxxxxx.com 443 ssl="CN=hanacloud.ondemand.com"
Save the interfaces file and exit.
- Step 3
Now check that your Python path is pointing to the directory where your Python Sybase Driver is located. Run the following command:Shell/BashCopy
env | grep PYTHONPATH
An example of what this path looks like is:
testcodedirectory, run the following command given below:Shell/BashCopy
After you run your python connection script, the output looks like this:
import sypydb conn = sypydb.connect("aseadmin", "YOUR_PASSWORD", "YOUR_INSTANCE_NAME", "chainxacts=off") cursor = conn.cursor () cursor.execute("select @@servername") row = cursor.fetchone() while row: print(row) row = cursor.fetchone()
sypydbto establish connection using username, password, and instance name information.
To verify the connection to your instance, run the following command:Shell/BashCopy
This will show your instance name as the output.
And that is it. You are connected to your SAP ASE database in SAP HANA Cloud using the Python Sybase Driver.
Now, you know how to connect to your instance using Python Sybase Driver. In the next tutorial, you can learn how to connect to an SAP ASE database in SAP HANA Cloud using
- Step 4
Fill in the Blank: <div> </div> Complete the following command used to check the location of Python Sybase Driver:<div> </div> env | grep ___________