This code shows how to connect a Python application with an InterSystems server using the Native API. It is used in the online exercise Python quickstart. Note that our code and supporting wheel files are designed for Python 3. If you want to use Python 2, please contact online.training@intersystems.com for more details.
Operating System | Version |
---|---|
Windows | Windows 10, Windows Server 2012, 2016, 2019 |
Mac | Apple macOS 10.13, 10.14 |
Linux |
|
nativeplaystocksTask1.py
: to make a connection to an instance of InterSystems IRIS Data Platform using the Native APInativeplaystocksTask6.py
: to see how to access directly the underlying structure within InterSystems IRIS
connection.config
: contains connection details for Native API, includingip
,port
,namespace
,username
, andpassword
.
-
Verify you have an instance of InterSystems IRIS, and an IDE that supports Python (such as VS Code). To download Community Edition locally, get an InterSystems IRIS installation kit from the evaluation kit download page. To use InterSystems IRIS in a container, get an image from the InterSystems Container Registry.
-
If you are using a local or container instance, load the sample stock data into InterSystems IRIS:
$ iris load http://github.com/intersystems/Samples-Stock-Data
If you are using InterSystems Labs, the sample stock data is already loaded. You can skip to the next step.
-
Clone the repo and open it in your IDE. Notes that all code and supported materials are in Solutions folder
-
In
connection.config
file, modify the host and password to be the correct values for your InterSystems IRIS instance. Although port and username are most likely the defaults, you should verify those values are correct. The port value should be the superserver port.
To connect using the Native API, you will need the DB-API driver. If InterSystems IRIS is installed locally or in a container on your development system, you can find the file in install-dir\dev\python
, where install-dir
is the InterSystems IRIS installation directory (install-dir
in a container is /usr/irissys
). You can also download the driver from the InterSystems IRIS driver distribution page. Put this driver in the Solutions directory.
Before installing the driver, make sure you are in Solutions directory of your terminal: cd Solutions
Install the driver using pip
:
pip install intersystems_irispython-3.2.0-py3-none-any.whl
- Run
python nativeplaystocksTask1.py
to make a connection to an instance of InterSystems IRIS Data Platform using the Native API. - Run
python nativeplaystocksTask6.py
to store and view data using globals, the underlying structure within InterSystems IRIS.