Skip to content

Latest commit

 

History

29 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

quickstarts-multimodel-python

In this repository

.
├── LICENSE
├── multimodelQS-new.py
├── multimodelQS.py
└── README.md

Guided tutorial

For a guided tutorial using this sample, visit Accessing Data in Python Using Multiple Data Models on the InterSystems learning site.

Starting IRIS

The easiest way to start InterSystems IRIS is using the community edition with docker:

docker run --name my-iris --publish 52773:52773 --publish 1972:1972 -d intersystems/iris-community:latest-em          For more information, see Deploy and Explore InterSystems IRIS Community Edition | InterSystems IRIS Data Platform

[!IMPORTANT] Before connecting to your InterSystems IRIS from Python you will need to log in and change the password (as the password is expired by default).

How to use this sample on your own

This code shows relational and native access from a Python application to InterSystems IRIS. Airport and location data is created and queried using SQL, including an implicit join (->) to follow a reference between tables, and a custom data structure is created using the Native SDK to handle route information between airports.

A single connection serves both access models: SQL runs through its cursors, and the same connection object backs the Native SDK.

  1. Start with an installation of Python and a running instance of InterSystems IRIS.
  2. Install the InterSystems IRIS Python DB-API driver, which also provides the Native SDK:
    pip install intersystems-irispython
    
  3. Clone this repository and open it in your preferred IDE.
  4. Edit multimodelQS-new.py. Update the connection information on lines 45-49 with information about your InterSystems IRIS server so that a connection can be established. Note that the port is the superserver port (1972 by default), not the web server port.
  5. Run multimodelQS-new.py. If all works correctly, you will see a list of airports output.
  6. If you would like to see how to store data using globals in Python:
    1. find and uncomment the following lines in run():
    # iris_native = iris.createIRIS(connection)  
    # store_airfare(iris_native)  
    # check_airfare(iris_native)  
    
    1. Run the script again.

    2. Enter departure airport: BOS

    3. Enter destination airport: AUS
      The output should say:

      Stored fare and distance data in ^airport global.
      Retrieved from ^airport global. The distance in miles between BOS and AUS is 1698.
      The following routes exist for this path:
      -AA150: 450 USD
      -AA290: 550 USD

      Other routes may be null. store_airfare() also stores routes from BOS to PHL and BIS, so try those pairs as well. Airports in the relational table that have no stored routes, such as SFO and ORD, report that no data is stored for the path.

About

quickstarts-multimodel-python

Resources

Stars

5 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages