Rechercher

Article
· Sept 2, 2024 4m de lecture

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.

Discussion (0)1
Connectez-vous ou inscrivez-vous pour continuer
Annonce
· Sept 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!👇

Discussion (0)0
Connectez-vous ou inscrivez-vous pour continuer
Question
· Sept 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
Discussion (3)2
Connectez-vous ou inscrivez-vous pour continuer
Résumé
· Sept 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
Annonce
· Sept 2, 2024

Resumen del mes de agosto, 2024

¿No habéis podido entrar en la Comunidad todo lo que os gustaría? ¡No os preocupéis! Os traemos un resumen de todo lo que hemos publicado en el mes de agosto. Seguid leyendo y no os lo perdáis ⬇️⬇️
Estadísticas generales
✓ publicaciones nuevas:
 16 artículos
 8 anuncios
 1 nueva pregunta
Top 10 Publicaciones más vistas
Top 5 Autores más populares
Todos los artículos
#InterSystems IRIS
Onboarding con InterSystems IRIS: una guía completa
Por Kristina Lauer
Interoperabilidad En Python: actualización soporte async
Por Alberto Fuentes
La exportación XML del proyecto de Studio omite inesperadamente los archivos webapp (CSP) cuando el nombre de la webapp no contiene barras oblicuas
Por Luis Angel Pérez Ramos
Usando Firebase Cloud Messaging con IrisFirebase FCM
Por Daniel Aguilar
[Estudio de caso] Control eficaz del código fuente en la sanidad
Por Ricardo Paiva
QuinielaML - Predicciones de la 1ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
Primera búsqueda vectorial en IRIS
Por Alberto Fuentes
QuinielaML - Predicciones de la 2ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
La extensión de ObjectScript de VS Code pueden mostrar documentos del servidor de sólo lectura
Por Alberto Fuentes
Acceso a Azure Blob Storage
Por Jose-Tomas Salvador
WebTerminal no funciona en IRIS 2024.2
Por Jose-Tomas Salvador
QuinielaML - Predicciones de la 4ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
Recorrer roles de forma recursiva
Por Alberto Fuentes
 
#InterSystems IRIS for Health
 
#Caché
 
#Open Exchange
 
Todos los anuncios
#InterSystems IRIS
 
#InterSystems Official
 
#IRIS contest
 
Todas las preguntas
#InterSystems IRIS
Error consultando foreign table en MySQL
Por Luis Angel Pérez Ramos
 
agosto, 2024Month at a GlanceInterSystems Developer Community
Discussion (0)1
Connectez-vous ou inscrivez-vous pour continuer