Nova postagem

Pesquisar

Resumo
· Set. 2, 2024

InterSystems Developers Publications, Week August 26 - September 01, 2024, Digest

Articles
#InterSystems IRIS
Announcements
#InterSystems IRIS
#Other
#Learning Portal
#InterSystems IRIS for Health
#Developer Community Official
Questions
#InterSystems IRIS
#Other
#InterSystems IRIS for Health
#Caché
error
By Richard Prouvot
JOB $SYSTEM.obj
By Richard Prouvot
OPEN A TERMINAL WINDOW VIA HREF TAG IN HTML
By Richard Prouvot
COMPARE ROUTINES
By Richard Prouvot
#Ensemble
August 26 - September 01, 2024Week at a GlanceInterSystems Developer Community
Artigo
· Set. 2, 2024 4min de leitura

IRIS Python nativo

Hola Comunidad

Anteriormente he experimentado con Python embebido en IRIS; sin embargo, aún no he tenido la oportunidad de implementar IRIS usando Python nativo. En este artículo, mi objetivo es esbozar los pasos que tomé para comenzar a aprender e implementar IRIS dentro de la fuente de Python. También me gustaría agradecer a @Guillaume Rongier y @Luis Angel Pérez Ramos su ayuda para resolver los problemas que encontré durante mi reciente instalación PIP de IRIS en Python, lo que finalmente permitió que funcionara correctamente.

Empecemos a escribir IRIS en python.

Lo primero es lo primero, tenéis que instalar el archivo intersystems_irispython-3.2.0-py3-none-any.whl desde el repositorio de github. He descargado e instalado en mi máquina de Windows.

py -m pip install intersystems_irispython-3.2.0-py3-none-any.whl

Verificado que los paquetes están instalados en mi máquina ejecutando py -m pip list

intersystems-irispython 3.2.0
iris                    0.0.5

 

Ahora listo para empezar a escribir el python. He creado un archivo .py e importar el paquete iris en la parte superior de la clase.

Ahora vamos a establecer la conexión a IRIS mediante el método de conexión y crear el uso del objeto de conexión para instanciar el objeto iris.IRIS mediante el uso de «createIRIS» y este es el paso crucial para proceder a otras operaciones.

import iris
impor time

args = {'hostname':'127.0.0.1', 'port':1972,'namespace':'LEARNING', 'username':'_SYSTEM', 'password':'SYS'}

try:
    """
    some other ways instead of kwargs
    conn = iris.connect(hostname='127.0.0.1', port=1972, namespace='LEARNING',username='_SYSTEM',password='SYS')
    """
    conn = iris.connect(**args)
    # A new IRIS object that uses the given connection.
    irispy = iris.createIRIS(conn)

    print('connected!')
except Exception as e:
    # Handling the exception and printing the error
    print(f"An error occurred: {e}")
    

 

Ahora hablemos de los Métodos para COS y global

Una vez que hayáis creado con éxito un objeto IRIS. Ahora estáis listos para utilizar diversas operaciones

set : Esta función se utiliza para definir los valores globales en la base de datos IRIS.

1. el primer parámetro es el valor establecido 

2. El segundo parámetro es el nombre global.

3. *args - tercer parámetro es subíndice(s)

def set_global(value=None,gbl=None,*args):
    #set method is in _IRIS from iris package
    irispy.set('set from irispy','mygbl','a',str(time.time()))
    print('global set done!')

set_global()

 

kill Esta función se utiliza para eliminar el global de la base de datos

def kill_global():
    irispy.kill('mygbl')
    print('global kill done!')

IsDefined: es igual a $data : verifica que existe

def data_isDefined():
    # equal to $data
    print(irispy.isDefined('mygbl','a')) # o/p 10
    print(irispy.isDefined('mygbl','a','1724996313.480835')) # o/p 1

nextSubscript: Es igual a $Order

irispy.nextSubscript(0,'mygbl','a')

tStart, tCommit y tRollback: lo mismo que TStart, TCommit, TRollback

def global_transaction_commit():
    irispy.tStart()
    print(irispy.getTLevel())
    irispy.set('set from irispy','mygbl','trans',str(time.time()))
    irispy.tCommit()

def global_transaction_rollback():
    irispy.tStart()
    print(irispy.getTLevel())
    irispy.set('set from irispy','mygbl','trans1',str(time.time()))
    irispy.tRollback() # tRollbackOne()

 

lock y unlock: por defecto incremental lock/exclusive lock

def global_lock():
    #default exclusive lock
    s = irispy.lock('',1,'^mygbl')
    time.sleep(10) # verify the lock in locktab
    irispy.unlock('','^mygbl')
    
def global_shared_lock():
    s = irispy.lock('S',1,'^mygbl')
    time.sleep(10)
    irispy.unlock('S','^mygbl')

node: subscript level igual que $Order

def node_traversal():
    # subscript level traversal like $Order
    for mrn in irispy.node('^mygbl'):
         for phone in irispy.node('^mygbl',mrn):
            print(f'patient mrn {mrn} and phone number: {phone}')
            
"""
o/p
patient mrn 912 and phone number: 3166854791
patient mrn 991 and phone number: 78050314
patient mrn 991 and phone number: 9128127353
"""

El nodo, el recorrido de valores y las definiciones de clase y sus miembros se tratan en el siguiente artículo.

Podéis consultar la documentación de IRIS para todas las funciones.

Discussão (0)1
Entre ou crie uma conta para continuar
Anúncio
· Set. 2, 2024

The 2nd InterSystems Japan Technical Writing Contest!

Hello developers!

Last year, for the first time, we held the Technical Article Contest on Japan's InterSystems Developer Community, and 📣 we are holding it again this year!📣

The topics are the same as last year, and you can submit any content related to InterSystems IRIS/InterSystems IRIS for Health.

🖋 InterSystems Japan Technical Article Contest – 2024: Articles related to IRIS 🖋

🎁 Participation prize:Everyone who submits a post will receive our👚Developer Community’s original T-shirt👕!!

🏆 Special Prize:Authors of three selected works will receive special prizes.

Updated on 30/8: Prize information added!Please check it out!👇

Discussão (0)0
Entre ou crie uma conta para continuar
Pergunta
· Set. 2, 2024

Embedded python still using old version of python after system upgrade

Hello,

I've recently updated the python version of a linux server running Red Hat Enterprise Linux 8.10 (Ootpa). We have an instance 2023.1 running there, and whenever I run the $System.Pyhthon.Shell() I can see it's still pointing to the old version. From within linux, it runs the latest one (we've change all the links to the new 3.11, so no scripts are broken).

So I guess the problem comes from the fact irispython is still compiled using old python version. So, how can I do to force IRIS to use the current version on the server, or update the irispython file?

Thanks!

3 Comments
Discussão (3)2
Entre ou crie uma conta para continuar
Resumo
· Set. 2, 2024

Publications des développeurs d'InterSystems, semaine August 26 - September 01, 2024, Résumé

August 26 - September 01, 2024Week at a GlanceInterSystems Developer Community