#Python

0 Followers · 456 Posts

Python is an interpreted high-level programming language for general-purpose programming. Created by Guido van Rossum and first released in 1991, Python has a design philosophy that emphasizes code readability, notably using significant whitespace

Official site.

InterSystems Python Binding Documentation.

Article Sylvain Guilbaud · Feb 1, 2024 5m read

Hello Community,

SQL language remains the most practical way to retrieve information stored in a database.

The JSON format is very often used in data exchange.

It is therefore common to seek to obtain data in JSON format from SQL queries.

Below you will find simple examples that can help you meet this need using ObjectScript and Python code.

ObjectScript : using Dynamic SQL with %SQL.StatementJSON structures with %DynamicObject and %DynamicArray

1
2 466
Article Vadim Aniskin · Jan 31, 2024 3m read

Django, a high-level web framework written in Python, has become a staple for developers seeking a robust, efficient, and easy-to-learn solution for building web applications. Its popularity stems from its versatility, offering developers an efficient toolkit for building web applications. Integrating Django with InterSystems IRIS introduces a dynamic synergy, providing developers with a comprehensive web development and database management solution. That's why on the Ideas Portal, @Evgeny Shvarov suggested that having Examples to work with IRIS from Django would be beneficial. In this

0
0 327
Question Weston Willett · Jan 2, 2024

Using the below python script I am getting : 

$ ./hello_world.py 
Traceback (most recent call last):
  File "/home/wwillett/dev/vscode-objectscript/Samples-python-helloworld/./hello_world.py", line 34, in <module>
    run()
  File "/home/wwillett/dev/vscode-objectscript/Samples-python-helloworld/./hello_world.py", line 21, in run
    connection = irisnative.createConnection(ip, port, namespace, username, password)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: * [ERROR_SEQUENCE_ERROR]

I have verified that the Gateway is running.

2
0 176
Article Luis Angel Pérez Ramos · Dec 29, 2023 6m read

It seems like yesterday when we did a small project in Java to test the performance of IRIS, PostgreSQL and MySQL (you can review the article we wrote back in June at the end of this article). If you remember, IRIS was superior to PostgreSQL and clearly superior to MySQL in insertions, with no big difference in queries.

Well, shortly after @Dmitry Maslennikov told me "Why don't you test it from a Python project?" Well, here is the Python version of the tests we previously performed using the JDBC connections.

6
3 867
Article Heloisa Paiva · Sep 22, 2022 4m read

Here you'll find a simple program that uses Python in an IRIS environment and another simple program that uses ObjectScript in a Python environment. Also, I'd like to share a few of the troubles I went trough while learning to implement this.

Python in IRIS environment

Let's say, for example, you're in an IRIS environment and you want to solve a problem that you find easy, or more efficient with Python.

You can simply change the environment: create your method as any other, and in the end of it's name and specifications, you add [ Language = python ]:

9
5 2146
Article Guillaume Rongier · Dec 18, 2023 13m read

1. IRIS RAG Demo

IRIS RAG Demo

This demo showcases the powerful synergy between IRIS Vector Search and RAG (Retrieval Augmented Generation), providing a cutting-edge approach to interacting with documents through a conversational interface. Utilizing InterSystems IRIS's newly introduced Vector Search capabilities, this application sets a new standard for retrieving and generating information based on a knowledge base. The backend, crafted in Python and leveraging the prowess of IRIS and IoP, the LLM model is orca-mini and served by the ollama server. The frontend is an chatbot written with Streamlit.

4
2 1017
Question Bryan Cass · Nov 10, 2023

I have an existing Python script that opens a child session using the pexpect library. But currently all it does is send hard-coded commands to the Cache process and expect a hard-coded response back in order to continue in the script.

I would like to run a Cache routine from the script, pass in a parameter, and wait for a response that will be different every time (a date, in this case). So the call would be something like D $$Tag^Routine(parameter) and wait for the routine to complete and return the response.

3
0 377
Article Muhammad Waseem · Nov 16, 2023 9m read

Hi, Community!

This article is an overview of SQLAlchemy, so let's begin!

SQLAlchemy is the Python SQL toolkit that serves as a bridge between your Python code and the relational database system of your choice. Created by Michael Bayer, it is currently available as an open-source library under the MIT License. SQLAlchemy supports a wide range of database systems, including PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server, making it versatile and adaptable to different project requirements.

8
3 843
Article Evgeny Shvarov · Sep 3, 2023 5m read

While starting the development with IRIS we have a distribution kit or in case of Docker we are pulling the docker image and then often we need to initialize it and setup the development environment. We might need to create databases, namespaces, turn on/off some services, create resources. We often need to import code and data into IRIS instance and run some custom code to init the solution.

1
3 691
Article Niels Genne · Nov 24, 2023 4m read

How can IRIS productions be deployed more quickly and with greater peace of mind?

The aim of interoperability productions is to enable you to connect systems in order to transform and route messages between them. To connect systems, you develop, configure, deploy and manage productions that integrate several software systems.

That’s what the InterSystems documentation on its reference website tells us, but what do you actually have to do to deploy a production ?

1
0 293
Question Yone Moreno · Nov 24, 2023

Hello,

First of all thanks for your time, thoughts, teaching and help:

We wonder how could we get the metrics from http://[Ip]:[Port]/api/monitor/metrics and use them in Kibana to chart statistics.

We would like to ask you how do you use the api monitor metrics, and as a second question, how would you suggest to utilize them in a third party software as Kibana to chart them.
 

We have thought to do the following:

0
1 175
Article Alex Woodhead · Jun 12, 2023 3m read

This article is a simple quick starter (what I did was) with SqlDatabaseChain.

Hope this ignites some interest.

Many thanks to:

sqlalchemy-iris author @Dmitry Maslennikov

Your project made this possible today.

The article script uses openai API so caution not to share table information and records externally, that you didn't intend to.

A local model could be plugged in , instead if needed.

Creating a new virtual environment

7
3 3532
Question Augustin MADET · Oct 24, 2023

import os

# Get environment variables
db_host = os.getenv('DB_HOST')
db_port = os.getenv('DB_PORT')
db_namespace = os.getenv('DB_NAMESPACE')
db_username = os.getenv('DB_USERNAME')
db_password = os.getenv('DB_PASSWORD')

# Create a database connection
conn = irisnative.createConnection(db_host, db_port, db_namespace, db_username, db_password)

# Create an IRIS instance from this connection
iris_native = irisnative.createIris(conn)

status = iris_native.classMethodValue('%SYSTEM.OBJ', 'Load', 'Production.cls', 'ck')

3
0 193
Article Dmitry Maslennikov · Aug 22, 2023 12m read

For the upcoming Python contest, I would like to make a small demo, on how to create a simple REST application using Python, which will use IRIS as a database. Using this tools

  • FastAPI framework, high performance, easy to learn, fast to code, ready for production
  • SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL
  • Alembic is a lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python.
  • Uvicorn is an ASGI web server implementation for Python.
5
2 490
Question Padmaja Konduru · Oct 16, 2023

Could you please help anyone how to import Python package in %SYSTEM package and to use python methods to write in object script class?

I used the following link to install the Python but I can't see the Python package in %SYSTEM package and my program throwing the Class Does not exist error?

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cl…

Please help on this..

5
0 656
Question Pietro Di Leo · Oct 13, 2023

Hi everyone, 

I'm attempting to compile a basic Python code on a remote server, but it appears that the compiler doesn't recognize the language.

The remote server is running a virtual machine with Oracle Linux Server 7.9 (64-bit), and it has IRIS for UNIX (Red Hat Enterprise Linux for x86-64) 2021.1 (Build 215U) [HealthConnect:3.3.0] installed.

When I try to compile a script that includes a Python ClassMethod, such as this "testpy.cls":

ClassMethod python() As%Status [ Language = python ]
{
    # prova python
    print("hello world")
}
4
0 316
Question Jonathan Lent · Sep 25, 2023

All,

I've asked my teammate to open a WRC on this issue, but wanted to open the discussion to see if maybe we aren't the first people to see this issue.

The code we are deploying is a COS object with some Python methods. The code works fine locally on the developer's machine. However, when the business process runs in the server environment, we see the following when COS code attempts to call a [Language = python] method:

5
0 357
Article Alex Woodhead · Jun 13, 2023 3m read

Yet another example of applying LangChain to give some inspiration for new community Grand Prix contest.

I was initially looking to build a chain to achieve dynamic search of html of documentation site, but in the end it was simpler to borg the static PDFs instead.

Create new virtual environment

mkdir chainpdf

cd chainpdf

python -m venv .

scripts\activate 

pip install openai
pip install langchain
pip install wget
pip install lancedb
pip install tiktoken
pip install pypdf

set OPENAI_API_KEY=[ Your OpenAI Key ]

python

Prepare the docs

4
2 1299