Nova postagem

查找

Pergunta
· Mar. 2

IO-Redirect package on Linux

Hi,

Has anyone used 'IO-Redirect' package?

https://openexchange.intersystems.com/package/io-redirect

IRIS for me runs on a Linux server.

I want the package to be able to supply "answers" from a Linux OS file in response to a program run as follows:
do ^ADMIN
I'm assuming that the program does objectscript reads from the terminal

Questions

1. Is docker required? Docker is not installed on the server.
2. Would the package be able to handle redirect I/O in this case?
    Would I have to write extra code (objectscript) to read the Linux file as a "stream"?
3. How would I  install the package? Would I have to download the package first? 
4. In the program most of the read from terminal require a <CR> but some read from terminal do not require a <CR>
    I'm assuming that the read that do not require a <CR> read the input character by character.
   Would the package handle this situation?
4. Would it be easy to convert the program to read the input directly from an OS file?

Thanks in advance

2 Comments
Discussão (2)2
Entre ou crie uma conta para continuar
Artigo
· Mar. 2 8min de leitura

Parallel Query Processing - (System-wide and Query-based)

Parallel query hinting boosts certain query performances on multi-processor systems via parallel processing. The SQL optimizer determines when this is beneficial. On single-processor systems, this hint has no effect.

Parallel processing can be managed by:

  1. Setting the auto parallel option system-wide.
  2. Using the %PARALLEL keyword in the FROM clause of specific queries.

%PARALLEL is ignored when it applied to:

Discussão (0)1
Entre ou crie uma conta para continuar
Artigo
· Mar. 2 5min de leitura

SQLAchemy-iris with the latest version Python driver

After so many years of waiting, we finally got an official driver available on Pypi

Additionally, found JDBC driver finally available on Maven already for 3 months,  and .Net driver on Nuget more than a month.

 As an author of so many implementations of IRIS support for various Python libraries, I wanted to check it. Implementation of DB-API means that it should be replaceable and at least functions defined in the standard. The only difference should be in SQL.

And the beauty of using already existing libraries, that they already implemented other databases by using DB-API standard, and these libraries already expect how driver should work.

I decided to test InterSystems official driver by implementing its support in SQLAlchemy-iris library.

executemany

Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters.

Very helpful function, whish let insert multiple rows at once. Let's start with a simple example

import iris

host = "localhost"
port = 1972
namespace = "USER"
username = "_SYSTEM"
password = "SYS"
conn = iris.connect(
    host,
    port,
    namespace,
    username,
    password,
)

with conn.cursor() as cursor:
    cursor = conn.cursor()

    res = cursor.execute("DROP TABLE IF EXISTS test")
    res = cursor.execute(
        """
    CREATE TABLE test (
            id IDENTITY NOT NULL,
            value VARCHAR(50)
    ) WITH %CLASSPARAMETER ALLOWIDENTITYINSERT = 1
    """
    )

    cursor = conn.cursor()
    res = cursor.executemany(
        "INSERT INTO test (id, value) VALUES (?, ?)", [
            (1, 'val1'),
            (2, 'val2'),
            (3, 'val3'),
            (4, 'val4'),
        ]
    )

This is working fine, but what if we need to insert only one value per row.

    res = cursor.executemany(
        "INSERT INTO test (value) VALUES (?)", [
            ('val1', ),
            ('val2', ),
            ('val3', ),
            ('val4', ),
        ]
    )

This unfortunately leads to an unexpected exception

RuntimeError: Cannot use list/tuple for single values

By some reason, one value per row is allowed, and InterSystems requires using a different way

    res = cursor.executemany(
        "INSERT INTO test (value) VALUES (?)", [
            'val1',
            'val2',
            'val3',
            'val4',
        ]
    )

This way it's working fine

fetchone

Fetch the next row of a query result set, returning a single sequence, or None when no more data is available.

For instance simple example on sqlite

import sqlite3
con = sqlite3.connect(":memory:")

cur = con.cursor()
cur.execute("SELECT 1 one, 2 two")
onerow = cur.fetchone()
print('onerow', type(onerow), onerow)
cur.execute("SELECT 1 one, 2 two union all select '01' as one, '02' as two")
allrows = cur.fetchall()
print('allrows', type(allrows), allrows)

gives

onerow <class 'tuple'> (1, 2)
allrows <class 'list'> [(1, 2), ('01', '02')]

And with InterSystems driver

import iris

con = iris.connect(
    hostname="localhost",
    port=1972,
    namespace="USER",
    username="_SYSTEM",
    password="SYS",
)

cur = con.cursor()
cur.execute("SELECT 1 one, 2 two")
onerow = cur.fetchone()
print("onerow", type(onerow), onerow)
cur.execute("SELECT 1 one, 2 two union all select '01' as one, '02' as two")
allrows = cur.fetchall()
print("allrows", type(allrows), allrows)

by some reasons gives

onerow <class 'iris.dbapi.DataRow'> <iris.dbapi.DataRow object at 0x104ca4e10>
allrows <class 'tuple'> ((1, 2), ('01', '02'))

What is DataRow, why not tuple or at least a list

Exceptions

Standard describes a variety of exception classes that the driver is supposed to use, in case if something is wrong. And the InterSystems driver does not use it at all, just raising RunTime error for any reason, which is not part of the standard anyway.

Application may rely on the exception type happening, and behave accordingly. But InterSystems driver does not provide any difference. And another issue, SQLCODE would help, but it needs to be parsed out of error message

Conclusion

So, during testing I found multiple bugs

  • Random errors happening at any time <LIST ERROR> Incorrect list format, unsupported type for IRISList; Details: type detected : 32
    • will work ok, if you try again right after the error
  • Caught some segmentation faults, don't even know how it happens
  • Unexpected result from fetchone function
  • Unexpected way of working of executemany function, for one value rows
  • Exceptions not implemented at all, different errors should raise different exceptions, and applications rely on it
  • Can break Embedded Python if installed next to IRIS
    • due to the same name used by Embedded Python and this driver, it overrides what's already installed with IRIS and may break it

 

SQLAlchemy-iris now supports the official InterSystems driver, but due to incompatibility with Embedded Python and several bugs discovered during testing. Install with this command, with the defined extra

pip install sqlalchemy-iris[intersystems]

And simple usage, URL should be iris+intersystems://

from sqlalchemy import Column, MetaData, Table
from sqlalchemy.sql.sqltypes import Integer, VARCHAR
from sqlalchemy import create_engine
from sqlalchemy.orm import DeclarativeBase


DATABASE_URL = "iris+intersystems://_SYSTEM:SYS@localhost:1972/USER"
engine = create_engine(DATABASE_URL, echo=True)

# Create a table metadata
metadata = MetaData()


class Base(DeclarativeBase):
    pass
def main():
    demo_table = Table(
        "demo_table",
        metadata,
        Column("id", Integer, primary_key=True, autoincrement=True),
        Column("value", VARCHAR(50)),
    )

    demo_table.drop(engine, checkfirst=True)
    demo_table.create(engine, checkfirst=True)
    with engine.connect() as conn:
        conn.execute(
            demo_table.insert(),
            [
                {"id": 1, "value": "Test"},
                {"id": 2, "value": "More"},
            ],
        )
        conn.commit()
        result = conn.execute(demo_table.select()).fetchall()
        print("result", result)


main()

Due to bugs in InterSystems driver, some features may not work as expected. And I hope it will be fixed in the future

7 Comments
Discussão (7)5
Entre ou crie uma conta para continuar
Anúncio
· Mar. 2

InterSystems Open Exchange Applications Digest, February 2025

Hello and welcome to the February 2025 Open Exchange Recap.
General Stats:
9 new apps in February
445 downloads in February
1,041 applications all time
39,115 downloads all time
3,049 developers joined
New Applications
Monitoring IRIS with Prometheus and Grafana
By Stav Bendarsky
sql-stats-api
By Lorenzo Scalese
IKO Guaranteed QoS
By Ariel Glikman
iris-fhir-io-demo
By Laura Blázquez García
objectscript-copilot-demo
By Evgeny Shvarov
memoria
By Joel Espinoza
intersystems-objectscript-class-diagram-view
By sdfsdf sadfsdaf
Mimic-SQL-Host-Variables
By Robert Cemper
rabbit-iris-sample
By Yuri Marx
New Releases
IRIS apiPub by Claudio Devecchi
v1.1.82
bug fixes & improvements
v1.1.83
bug fixes
bdb-sql-utils by Benjamin De Boe
v0.7.5
  • default to fast estimate for TableSize() query
  • skip tables that are mere projections of collections and not classes of their own
SAML-COS by David González Buisán
v1.2.0
Add Audience Restriction tag
Embedded Git by Timothy Leavitt
v2.10.0

[2.10.0] - 2025-02-10

Added

  • LoadProductionsFromDirectory method to help custom deployment scripts load decomposed productions from the repository (#670)
  • Added ability to reset head / revert most recent commit (#586)
  • Changes deployed through Git are now logged in a new table SourceControl_Git.DeploymentLog

Fixed

  • Fixed not showing warnings on Studio (#660)
  • Fixed business processes and rules not being added to source control automatically (#676)
  • Embedded Git commits settings when cloning empty repo to avert any issues
  • Fixed Import All options not importing the Embedded Git configuration file
  • That configuration file now imports before everything else (#697)
  • Improved performance of IDE editing and baselining of decomposed productions
  • Fixed Discard / Stash not working on deletes (#688)
  • Fixed errors deploying decomposed production changes on Windows network drives (#696)
  • Improved performance of deploying changes to decomposed production items (#690)
  • Fixed errors saving decomposed productions when invalid items in item cache (#701)
  • Removed unnecessary Add and Remove menu items from decomposed productions (#701)
Intersystems-Monitoring by Teunis Stolker
v1.0.22
Tracing is off by default
SQL DATA LENS by Andreas Schneider
v3.20
This is an AI generated release news. Have fun ;-)

SQL DATA LENS 3.20 Release – Elevate Your SQL Experience!

Welcome to the exhilarating new release of
SQL DATA LENS 3.20
! This version is packed with dynamic enhancements and powerful upgrades designed to streamline your SQL workflows, boost performance, and provide a richer user experience. Whether you’re connecting to new data sources or optimizing your queries, this release has something to thrill every SQL enthusiast.

What’s New?

 

Cutting-Edge Drivers & Library Enhancements
  • InterSystems IRIS Integration:
    • New Driver 3.10.2
      from InterSystems IRIS 2024.x
    • New Driver 3.9.0
      from InterSystems IRIS 2024.2 Expand your connectivity with these advanced drivers, ensuring smoother integration with your enterprise databases.
  • Upgraded Internal Libraries:
    Enjoy improved performance and reliability with a comprehensive upgrade of many internal libraries and our SQL Formatter.
  • Enhanced Database Drivers:
    • MariaDB:
      Upgraded to mariadb-java-client-3.4.1.jar
    • H2:
      Now running on h2-2.3.232.jar
    • PostgreSQL:
      Enhanced with postgresql-42.7.4.jar
    • Access:
      Updated to ucanaccess-5.0.1
    • Firebird:
      Now powered by jaybird-5.0.5.java11
    • SQLite:
      Boosted with sqlite-jdbc-3.46.1.0_win64
    • Trino:
      Improved with trino-jdbc-468
    • MS SQL Server:
      Upgraded to mssql-jdbc-12.8.1
    • DuckDB:
      Now at version 1.1.3

 

Performance & Usability Breakthroughs
  • Java Runtime Environment Upgrade:
    We’ve leaped from Java 11.0.14 to the state-of-the-art
    Java 21.0.3
    . Enjoy:
    • Near-zero pause times and enhanced thread scalability
    • Lightweight concurrency with a low memory footprint
    • SIMD parallelism for data-heavy tasks
    • Faster execution, reduced warm-up times, and lower memory usage These performance improvements translate into a snappier, more resource-efficient application experience.
  • New Runtime Environment Info Dialog:
    Quickly access and copy runtime environment details with our sleek new info dialog.

 

Feature Enhancements for Streamlined Workflows
  • Drag & Drop File Analysis:
    Simply drag and drop CSV, Parquet, or JSON files into DuckDB. Watch as SQL DATA LENS automatically generates DESCRIBE & SUMMARIZE statements, expediting your file analysis process.
  • Improved Stored Procedures:
    Generation of CALL scripts is now more intuitive and robust.
  • Revamped SQL Editor:
    • Smart Cell Analysis:
      The result set reading now stops at the first faulty cell, while still capturing detailed row, column, and error value information for easier troubleshooting.
    • Toolbar-Driven Configurations:
      Access settings for result display (text/grid), new tab outputs, and execution plans directly from the toolbar. Plus, enjoy an improved layout for text results that makes your data insights crystal clear.
  • Enhanced DB Diagrams:
    The diagram feature now processes VIEWs and can display system objects when selected, giving you a comprehensive visual representation of your database structure.

Bug Fixes & Stability Improvements

  • Server Navigator:
    Sorting issues have been resolved to ensure a smooth navigation experience.
  • SQL Editor Execution Plan:
    The execution plan display is restored and fully operational.
  • TableViewer:
    Fixed a null pointer exception when viewing linked FOREIGN TABLEs.
  • Session Restoration:
    Resolved an issue where SQL Editor settings were not restored after restarting SQL DATA LENS.
  • XML Library Update:
    Removal of an outdated XML library introduces a breaking change for DB diagrams, paving the way for a cleaner, more efficient system.

Get Ready to Transform Your SQL Workflow

SQL DATA LENS 3.20 is here to redefine your SQL analysis experience with advanced drivers, stellar performance upgrades, and smarter, user-centric features. Dive in and explore the enhanced functionalities that will empower you to analyze, troubleshoot, and visualize data like never before.
Thank you for being a valued user of SQL DATA LENS —your feedback and support drive our continuous innovation. Happy querying!
Most downloaded
MDX2JSON
By Eduard Lebedyuk
DeepSeeWeb
By Anton Gnibeda
ObjectScript-Math
By Peter Steiwer
WebTerminal
By Nikita Savchenko
Embedded Git
By Timothy Leavitt
ssl-client
By Evgeny Shvarov
iris-web-swagger-ui
By Maks Atygaev
passwordless
By Sergey Mikhailenko
iris-cron-task
By Evgeny Shvarov
csvgen
By Evgeny Shvarov
February, 2025Month at a GlanceInterSystems Open Exchange
Discussão (0)1
Entre ou crie uma conta para continuar