Find

Article
· Aug 18 4m read

Un guide pour débutants sur la création de tables SQL et leur visualisation en tant que classes

Récompense d’août pour les articles sur Global Masters a retenu mon attention, et l'un des sujets proposés m'a semblé très intéressant quant à son utilisation future dans mon enseignement. Voici donc ce que j'aimerais dire à mes étudiants à propos des tables dans IRIS et de leur corrélation avec le modèle objet.

Tout d'abord, InterSystems IRIS dispose d'un modèle de données unifié. Cela signifie que lorsque vous travaillez avec des données, vous n'êtes pas enfermé dans un paradigme unique. Les mêmes données sont accessibles et manipulables comme une table SQL traditionnelle, comme un objet natif, ou même comme un tableau multidimensionnel (global). Cela signifie que lorsque vous créez une table SQL, IRIS crée automatiquement une classe d'objet correspondante. Lorsque vous définissez une classe d'objet, IRIS la rend automatiquement disponible sous forme de table SQL. Les données elles-mêmes ne sont stockées qu'une seule fois dans le moteur de stockage multidimensionnel performant d'IRIS. Le moteur SQL et le moteur objet sont simplement des « optiques » différentes pour visualiser et travailler avec les mêmes données.

Commençons par examiner la corrélation entre le modèle relationnel et le modèle objet :

Relationnel Objet
Table Classe
Colonne Propriété
Ligne Objet
Clé primaire Identifiant d'objet

La corrélation n'est pas toujours exacte, car plusieurs tables peuvent représenter une même classe, par exemple. Mais c'est une règle générale.

Dans cet article, je vais expliquer comment créer une table en listant ses colonnes.

Approche la plus simple :

CREATE TABLE [IF NOT EXISTS] table (
   column1 type1 [NOT NULL], 
   column2 type2 [UNIQUE], 
   column3 type3 [PRIMARY KEY]
   ...
   [CONSTRAINT fKeyName FOREIGN KEY (column) REFERENCES refTable (refColumn)]
)

[ ] désigne les parties facultatives.

Créons une table DC.PostType, composée de trois colonnes : TypeID (clé primaire), Name et Description:

CREATE TABLE DC.PostType (
  TypeID        INT NOT NULL,
  Name          VARCHAR(20), 
  Description   VARCHAR(500),
  CONSTRAINT Type_PK PRIMARY KEY (TypeID)
)

En conséquence, nous obtiendrons la classe suivante après avoir exécuté l'instruction SQL ci-dessus :

/// 
Class DC.PostType Extends %Persistent [ ClassType = persistent, DdlAllowed, Final, Owner = {UnknownUser}, ProcedureBlock, SqlRowIdPrivate, SqlTableName = PostType ]
{

Property TypeID As %Library.Integer(MAXVAL = 2147483647, MINVAL = -2147483648) [ Required, SqlColumnNumber = 2 ];
Property Name As %Library.String(MAXLEN = 20) [ SqlColumnNumber = 3 ];
Property Description As %Library.String(MAXLEN = 500) [ SqlColumnNumber = 4 ];
Parameter USEEXTENTSET = 1;
/// Bitmap Extent Index auto-generated by DDL CREATE TABLE statement.  Do not edit the SqlName of this index.
Index DDLBEIndex [ Extent, SqlName = "%%DDLBEIndex", Type = bitmap ];
/// DDL Primary Key Specification
Index TypePK On TypeID [ PrimaryKey, SqlName = Type_PK, Type = index, Unique ];
Storage Default
{
<Data name="PostTypeDefaultData">
<Value name="1">
<Value>TypeID</Value>
</Value>
<Value name="2">
<Value>Name</Value>
</Value>
<Value name="3">
<Value>Description</Value>
</Value>
</Data>
<DataLocation>^B3xx.DXwO.1</DataLocation>
<DefaultData>PostTypeDefaultData</DefaultData>
<ExtentLocation>^B3xx.DXwO</ExtentLocation>
<IdFunction>sequence</IdFunction>
<IdLocation>^B3xx.DXwO.1</IdLocation>
<Index name="DDLBEIndex">
<Location>^B3xx.DXwO.2</Location>
</Index>
<Index name="IDKEY">
<Location>^B3xx.DXwO.1</Location>
</Index>
<Index name="TypePK">
<Location>^B3xx.DXwO.3</Location>
</Index>
<IndexLocation>^B3xx.DXwO.I</IndexLocation>
<StreamLocation>^B3xx.DXwO.S</StreamLocation>
<Type>%Storage.Persistent</Type>
}

}

Observations clés :

  • TABLE DC.PostType est devenue la Classe DC.PostType.
  • La classe Extends %Persistent, qui indique à IRIS de stocker ses données dans la base de données.
  • VARCHAR est devenu %String.
  • INT est devenu %Integer.
  • La contrainte PRIMARY KEY a créé un index avec le mot-clé PrimaryKey.

Vous pouvez désormais utiliser cette table/classe de n'importe quel côté, par exemple en utilisant SQL :

INSERT INTO DC.PostType (TypeID, Name, Description) VALUES (1, 'Question', 'Ask a question from the Community')

La création de tables à l'aide de SQL est bien plus complexe. Veuillez lire la documentation fournie ci-dessous.

Discussion (0)1
Log in or sign up to continue
Article
· Aug 18 7m read

Introduction to Interoperability on Python (IoP)

Interoperability on Python (IoP) is a proof-of-concept project designed to showcase the power of the InterSystems IRIS Interoperability Framework when combined with a Python-first approach.IoP leverages Embedded Python (a feature of InterSystems IRIS) to enable developers to write interoperability components in Python, which can seamlessly integrate with the robust IRIS platform. This guide has been crafted for beginners and provides a comprehensive introduction to IoP, its setup, and practical steps to create your first interoperability component. By the end of this article, you will get a clear understanding of how to use IoP to build scalable, Python-based interoperability solutions.

IoP is particularly valuable for developers working with InterSystems IRIS or IRIS for Health, since it simplifies the creation of Business Services, Business Processes, and Business Operations that use Python. Such an approach reduces the reliance on ObjectScript (the traditional language for IRIS development), making it more accessible to Python developers.


Why Should We Use IoP?

IoP offers several advantages for developers:

  1. Python-First Development: Python is a widely adopted, beginner-friendly language with a rich ecosystem of libraries. IoP allows developers to leverage their Python expertise within the IRIS ecosystem.
  2. Simplified Interoperability: IoP abstracts complex ObjectScript-based configurations, enabling faster development of interoperability components.
  3. Healthcare Applications: IoP is particularly suited for healthcare integrations, such as those involving FHIR (Fast Healthcare Interoperability Resources), due to IRIS for Health's robust support for healthcare standards.
  4. Community and Open Source: IoP is available on PyPI and GitHub and has active community support, including contributions from developers like Guillaume Rongier (a developer evangelist for InterSystems).

Prerequisites

Before diving into IoP, ensure you have the following:

  • InterSystems IRIS or IRIS for Health: A local installation or a Docker container running IRIS (Community Edition is sufficient for testing).
  • Python 3.10 or later: Required for running IoP and its dependencies.
  • Basic Python Knowledge: Familiarity with Python classes, functions, and package installation.

In this tutorial, we will use a local IRIS installation to create an InterSystems IRIS production featuring a Python-based Business Operation that logs a 'Hello World' message upon receiving a request. It should showcase seamless integration with the IRIS Interoperability Framework.

The following steps outline the process for achieving this goal:

  • Step 1: Set Up the Virtual Environment
  • Step 2: Install IoP Package
  • Step 3: Set Up Environment Variables for IRIS Connection
  • Step 4: Initialize the IoP Module in IRIS by using the Command line interface (CLI)
  • Step 5: Create Python Business Operation: A Hello World Example
  • Step 6: Migrate IoP components into IRIS
  • Step 7: Production Overview
  • Step 8: Test the Production Operation component

 

Let's begin with the step 1.

Step1: Set Up the Virtual Environment

First, set up a Python virtual environment to isolate your project’s dependencies, ensuring compatibility with IoP and InterSystems IRIS. A virtual environment is a self-contained directory with a specific Python version and the packages required for your project. Such a setup prevents conflicts with other Python projects and streamlines the development process. For this tutorial, create a folder named IOP to organize your project files.

Navigate to the IOP folder and run the following command to set up the virtual environment:

python -m venv .venv

This command creates a .venv directory in your IOP folder, containing a Python interpreter and any packages you install for your IoP project.

To activate the virtual environment on Windows, apply the next command:

.venv\Scripts\activate

 

For Unix or MacOS, utilize the  below command:

source .venv/bin/activate

 

Step 2 : Install IoP Package

With your virtual environment activated, install the iris-pex-embedded-python package, the core dependency for your IoP project, to enable Python-based interoperability with InterSystems IRIS. Run the following command in your terminal:

pip install iris-pex-embedded-python

This command installs the iris-pex-embedded-python package and its dependencies from the Python Package Index (PyPI) into your virtual environment. After installation, you can use the IoP module to create Python-based interoperability components, such as the Business Operation for your IoP project.

 

Step 3: Set Up Environment Variables for IRIS Connection

To connect your IoP project to InterSystems IRIS, configure the environment variables specifying the connection details. For this tutorial, we will operate a local IRIS instance with an interoperability-enabled namespace named IOP:


For Windows:
  


For Unix or MacOS:  

export IRISINSTALLDIR=<installation_directory>
export IRISUSERNAME=<username>
export IRISPASSWORD=<password>
export IRISNAMESPACE=<namespace>


Step 4: Initialize the IoP Module in IRIS by using the Command line interface (CLI)

The iop command line interface (CLI) is a powerful tool for developers working with the library. In addition to --init and --migrate, it provides commands for managing your interoperability components directly from the terminal.

Some of the key commands include the following:

  • iop --start: Starts a production defined in your settings.py file.
  • iop --stop: Stops a running production.
  • iop --status: Checks the status of a production.
  • iop --log: Views the logs from your running components.
  • iop --init: Initialize the IoP module in iris
  • iop --migrate: Migrate production and classes with the settings file.

Run the IoP CLI command below to initialize the IoP module in IRIS:

iop --init

This command performs the necessary configuration within your InterSystems IRIS instance, allowing it to locate and use the Python modules you create.
 

In the IRIS Management Portal, navigate to System Administration > Configuration > Classes. Select the IOP namespace, and enable the Show Generated Items check box to view the IoP-generated classes, e.g., PEX.MyBo. It will confirm that the IoP module has been successfully registered in your IRIS instance.

  

Step 5: Create Python Business Operation: A Hello World Example
 

Let's create a simple "Hello World" Business Operation to understand the basic structure of an IoP component.
This example will illustrate how to define a class that processes incoming messages and logs responses.
 

To do it, let's generate a new folder named hello_world.

mkdir hello_world

In that folder, create a new file called bo.py.

The core of your component is a Python class that inherits from BusinessOperation,which takes a message as input and returns a message as output. In between, it simply prints "Hello World" in the logs.

from iop import BusinessOperation

class MyBo(BusinessOperation):
    def on_message(self, request):
        self.log_info("Hello World")



Let's explain this code.

First, we import the BusinessOperation class from the iop module.

Then, we generate a class named MyBo that inherits from BusinessOperation.

Finally, we override the on_message method. This method is called when the Business Operation receives a message.

Step 6: Migrate IoP components into IRIS

To migrate IoP components into IRIS, we need to create a new file in the hello_world folder, named settings.py.

This file contains two main settings:

  • CLASSES : Contains the classes used in the project.
  • PRODUCTIONS : Includes the production name employed in the project.
from hello_world.bo import MyBo

CLASSES = {
    "MyIRIS.MyBo": MyBo
}

PRODUCTIONS = [
        {
            'MyIRIS.Production': {
                "@TestingEnabled": "true",
                "Item": [
                    {
                        "@Name": "Instance.Of.MyBo",
                        "@ClassName": "MyIRIS.MyBo",
                    }
                ]
            }
        } 
    ]


In this file, we import our MyBo class named MyIRIS.MyBo in IRIS, and add it to the CLASSES dictionary.

Then, we add a new production to the PRODUCTIONS list. This production will retain our MyBo class instance called Instance.Of.MyBo.

    With the iop command, we can migrate the components into IRIS.

    iop --migrate /path/to/hello_world/settings.py
    

    This command will generate the production in IRIS and add the MyBo class to it.


    Step7: Production Overview

    The following production has been created by iop --migrate command:

    Below you can see the operation details (%classname refers to the class name in our bo.py file, %module refers to the Python file name, and %classpaths contains the path to the Python file)
     

      
    Step 8: Test the Production Operation component

    To test the production, select the Business Operation. Then, go to the Actions tab and press the Test button.
    Select Ens.Request as the Request Type, click the Invoke Testing Service button, and then click Visual Trace to view the details:
     

     

    Conclusion

    Interoperability on Python (IoP) opens up the InterSystems IRIS Interoperability Framework to Python developers, streamlining the process of building robust and scalable integrations. This guide has walked you through the installation of IoP, the configuration of a development environment, and the creation of a Business Operation. With IoP, you can harness the simplicity of Python alongside the power of IRIS to connect systems. For more details, view the documentation


    Thanks
     

    6 Comments
    Discussion (6)3
    Log in or sign up to continue
    Article
    · Aug 18 3m read

    Practical ObjectScript Coding: From JSON to Globals to SQL

    While starting with Intersystems IRIS or Cache, developers often encounter three core concepts: Dynamic Objects, Globals & Relational Table. Each has its role in building scalable and maintainable solutions. In this article, we'll walk through practical code examples, highlight best practices, and show how these concepts tie together. 

    1. Working with Dynamic Objects:

    Dynamic objects (%DynamicObject and %DynamicArray) allow developers to manipulate JSON-like structures directly in Objectscript. They are especially useful for modern applications that need to parse, transform or generate JSON.

    Example: Creating & Manipulating Dynamic Objects

        // Create a Dynamic object
        Set obj - {}
    
        // Add properties
        Set obj.name = "Vachan"
        Set obj.age = 25
        // Nested objects
        Set obj.address = {"city":"Bengaluru", "zip":"560000"}
        
        // Add an Array
        Set obj.skills = ["Objectscript", "SQL"]
        
        // Convert to JSON string
        Set json = obj.%ToJSON()
        Write json,!
        
        // Parse JSON string back to an object
        Set parser = {}.%FromJSON(json)
        Write parser.name

    Best Practices:

    • Always validate JSON input with %FromJSON() to catch errors.
    • Use obj.%Get("property") when unsure if a property exists.
    • Favor %DynamicArray for list-like structures.

    2. Using Globals Effectively:

    Globals are hierarchical sparse arrays stored directly in the IRIS database engine. They are extremely fast and can store virtually any structure.

    Example: Storing Data in Globals

    // Store student data in a global
    SET ^Student(1,"Name") = "Alice"
    SET ^Student(1,"Age") = 29
    SET ^Student(2,"Name") = "Bob"
    SET ^Student(2,"Age") = 34
    // Retrieve data
    WRITE ^Student(1,"Name")  // outputs: Alice
    // Iterate over all students
    SET id=""
    FOR  SET id=$ORDER(^Student(id)) QUIT:id=""  {
        WRITE "Student ",id,": ",^Student(id,"Name")," (Age ",^Student(id,"Age"),")",!
    }

    Best Practices:

    • Define a clear global structure before coding (avoid ad-hoc keys).
    • Use globals for high-performance storage when SQL overhead is not needed.
    • For application data, prefer persistent classes with globals managed under the hood.

    3. Creating Relational SQL tables:

    In IRIS, relational tables can be created using both SQL DDL and persistent classes.

    Example: Creating a SQL Table via DDL

    CREATE TABLE Employee (
        ID SERIAL PRIMARY KEY,
        Name VARCHAR(50),
        Age INT,
        Department VARCHAR(50)
    );

    Example: Creating the same table as a Persistent Class

    Class Company.Employee Extends (%Persistent) {
        Property Name As %String(MAXLEN=50);
        Property Age As %Integer;
        Property Department As %String(MAXLEN=50);
    }

    Once compiled, this class automatically creates an underlying global and an SQL table. You can now use both ObjectScript and SQL:

    // Create and save an employee
    SET emp = ##class(Company.Employee).%New()
    SET emp.Name = "Charlie"
    SET emp.Age = 40
    SET emp.Department = "IT"
    DO emp.%Save()
    
    // Query employees with SQL
    &sql(SELECT Name, Age FROM Company.Employee)
    WHILE (SQLCODE=0) {
        WRITE "Employee: ",Name,", Age: ",Age,!
        FETCH NEXT
    }

    Best Practices:

    • Prefer persistent classes for maintainable applications.
    • Use SQL DDL for quick table definitions or integration with external systems.
    • Always define indexes for commonly queried properties.

     

    SUMMARY:

    Whether you are parsing JSON payloads, managing high-speed lookup data, or designing relational tables, understanding when to use dynamic objects, globals, or persistent classes is key to becoming an effective ObjectScript developer.

    2 Comments
    Discussion (2)1
    Log in or sign up to continue
    InterSystems Official
    · Aug 17

    InterSystems サポートプラットフォーム最新情報 Q3-2025

    2025年第3四半期の最新情報をお伝えします。

    3か月前の前回にご案内した重要なお知らせを、ここであらためて振り返ってみましょう。

    • IRIS 2025.1 で RHEL 10 サポートが追加されました。
    • 2025.3 では、すべてのオペレーティングシステムで OpenSSL 3 が使用されます。SUSE 15 sp6 は、SUSEを利用する IRISユーザのミニマムサポート OS となります。
    • ミニマムサポート CPU の基準が 2025.3 で引き上げられます。
    • 古い Windows Server オペレーティングシステム は 2025.3 でサポート対象外となります。

    初めてご覧になる方、はじめまして!この記事では、最近おこなわれた変更点や今後予定されている変更点に関する情報を、みなさまに共有させていただきます。ただ、将来の予測は難しい側面があり、ロードマップは約束されたものではないということを十分ご理解くださいませ。   

     

    InterSystems IRIS 本番環境用オペレーティングシステムと CPU アーキテクチャ

    ミニマムサポート CPU アーキテクチャ

    2024年、インターシステムズは、IRIS をより早くするために新しい CPU 命令を利用できるよう、すべての Intel および AMD ベースのサーバに関する ミニマムサポート CPU モデルを発表しました。IRIS 2025.3 ではこのリストが更新され、AVX、AVX2、BMI、BMI2 命令を利用する x86-64-v3 マイクロアーキテクチャ が必要となります。

    • Intel ベースのシステムを利用する場合、Haswell 以上が必要となります。
    • AMD ベースのシステムを利用する場合、Excavator 以上が必要となります。Piledriver および Steamroller はサポートされません。

    お使いの CPU がサポート対象かどうか確認するには、2023年の記事 CPU のマクロアーキテクチャファミリと命令セットの判定方法 をご参照ください。

     

    Red Hat Enterprise Linux

    • 今後予定されている変更点
      • RHEL 10 - Red Hat が RHEL 10 を5月20日にリリースしました。 InterSystems は 6月20日に RHEL 10 をサポートする IRIS 2025.1.0 をリリースしました。
        • IRIS 2025.2 以降は、RHEL 9 および 10 をサポートします。RHEL 8 のサポートは終了しました。
    • Red Hat のリリースライフサイクルについては こちら をご覧ください

     

    Ubuntu

    • 最近の変更点
      • Ubuntu 24.04.2 がリリースされ、マイナー OS 認証も問題なく完了しました。
    • Ubuntu のリリース履歴については こちら をご覧ください。

     

    SUSE Linux

    • 今後予定されている変更点
      • IRIS 2025.3 以降では、SUSE Linux Enterprise Server 15 SP6 以上が必要となります。 SLES 15 sp6 では、OpenSSL 3 を使用するオプションが追加されています。お客様に可能な限り安全なプラットフォームを提供するために、OpenSSL 3 を使えるよう IRIS 内部処理を変更する予定です。
      • IRIS 2025.3 で OpenSSL 3 に移行する準備として、IRIS 2025.2 for SUSE はリリースされませんでした。
    • SUSE ライフサイクルについては こちら をご覧ください。

     

    Oracle Linux

    • 今後予定されている変更点
      • Oracle Linux 10 のテストを開始しました。これまでの経験から、RHEL 10 をサポートする IRIS バージョンであれば問題なく動作すると考えています。
    • Oracle Linux のサポートポリシーについては こちら をご覧ください

     

    Microsoft Windows

    • 過去にお知らせ済みの変更点
      • IRIS 2025.1 以降で Windows Server 2025 がサポートされています。
    • 今後予定されている変更点
      • IRIS 2025.3 以降は、Windows Server 2016 と 2019 はサポートされません。
      • Microsoft は、Windows 12 のリリース予定を再度延期しました。 この時点でリリース予定を推測することは難しいです。 リリースされ次第、新OSのサポートに向けて動く予定です。
    • Microsoft のライフサイクルについては、こちら をご覧ください。

     

    AIX

    • 今後予定されている変更点
      • IBM は新しい Power 11 を7月にリリースしました。 夏の終わりから秋の初めにかけて、この新しいハードウェアをテスト予定です。 2025年第4四半期 もしくは 2026年第1四半期のニュースで、テスト結果のアップデートをお伝えする予定です
    • AIX のライフサイクルについては、こちら をご覧ください

     

    コンテナ

    • 過去にお知らせ済みの変更点
      • IRIS 2024.2 で、ベース コンテナ イメージを Ubuntu 22.04 から Ubuntu 24.04 に変更しました。
      • 現在、ベース IRIS コンテナに変更を行い、デフォルトでは、( ECP やミラーリングなどの) 内部トラフィックと、( ODBC や JDBC などの) 外部トラフィックとを、別のポートにすることを検討しています。こちらに関してご要望がございましたら、@Bob Kuszewski までご連絡ください。

     

    InterSystems IRIS 開発環境用オペレーティングシステムと CPU アーキテクチャ

    MacOS

    • 最近の変更点
      • IRIS 2025.1 で、ARM ベース および Intel ベース の MacOS 15 のサポートを追加しました。

     

    InterSystems コンポーネント

    • 今後予定されているリリース
      • InterSystems API Manager 3.10 がリリースされました。以前のバージョンの API Manager をご利用されている場合、新しい IRIS ライセンスキーが必要となります。
      • InterSystems Kubernetes Operator 3.8 がリリースされました。

     

    Caché ならびに Ensemble 本番環境用オペレーティングシステムと CPU アーキテクチャ

    • 過去にお知らせ済みの変更点
      • Caché ならびにEnsemble の最終メンテナンスリリースは 2027年第一四半期に予定されていること、あらためてご留意ください。想像より早くその日はやってきます。詳細は Jeff の記事 をご覧ください。

     

    InterSystems サポートプラットフォームに関するドキュメント

    サポート・プラットフォームに関する以下のドキュメントにて、正式なサポートリストを入手いただけます。

     

    以上になります。もし追加で知りたい情報がございましたら、ぜひコメントなどを通じてお知らせください。

    Discussion (0)0
    Log in or sign up to continue