Python
Python
This page outlines the steps to use the Python Driver for CData Connect Cloud.
Note:CData Connect Cloud でPython を設定して使用する前に、データソースをCData Connect Cloud アカウントに接続する必要があります。詳細は、Connections を参照してください。
Install the Driver
Follow these steps to download and install the driver:
-
Open the Client Tools page of CData Connect Cloud.
-
In the Dev Tools section, click Python.
-
Download and extract the setup archive for your operating system.
Follow the steps below for your operating system.
Windows Installation
-
In the extracted archive, open the
win
folder. -
Choose the folder for your Python version, and then the folder for your bitness. For example, if you have Python 3.9 and a 64-bit operating system, open the
win > Python39 > 64
folder. -
Open a command prompt and run
pip install
for the.whl
setup file. For example, a 64-bit Python 3.9 install would bepip install cdata_connect_connector-21.0.8049-cp39-cp39-win_amd64.whl
.
Mac and Unix Installation
-
In the extracted archive, open the
mac
orunix
folder. -
Open a Python terminal and run
pip install
for the appropriate.tar.gz
setup file. For example, a Python 3.9 install would bepip install cdata-connect-connector-21.0.8049-python39.tar.gz
.
Connect to CData Connect Cloud
Follow these steps for an example of how to connect to CData Connect Cloud from your Python code:
- Import
cdata.connect
, create a connection object, and and pass the connection string as an argument, as in the example below:import cdata.connect as mod conn = mod.connect("AuthScheme=OAuth;")
-
If you are not already logged into CData Connect Cloud, the OAuth login page opens in your default web browser. Log in to continue.
- You can execute SQL statements using this connection. For example, the commands below print all entries for Id in a MailChimp connection:
cur = conn.execute("SELECT Id FROM MailChimp1.MailChimp.AuthorizedApps") rs = cur.fetchall() for row in rs: print(row)
Connect to a Workspace
You can connect the Python client to a specific workspace as follows:
import cdata.connect as mod
conn = mod.connect("AuthScheme=OAuth;Workspace=MyWorkspace")
Learn More
To learn more information about using Python for CData Connect Cloud, click here.