Home Applications irisconns

irisconns

InterSystems does not provide technical support for this project. Please contact its developer for the technical assistance.
5
1 reviews
0
Awards
115
Views
0
IPM installs
0
0
Details
Releases (2)
Reviews (1)
Issues
Articles (1)
Read/prompt for IRIS connection info from configuration files

What's new in this version

Updating README with Environment Variable information.

irisconns

Create IRIS connections from configuration files

irisconns was created to help manage IRIS connections in your project using configuration files instead of hard-coding the configuration information in your project. Any missing information (such as username, password) will be prompted by the user’s terminal.

irisconns looks in irisconns or .irisconns files for connection information.

If a connection has been previously requested, the new request will immediately return the existing connection without prompting the user.

The environment variable CONN can also be used to change the default connection settings for irisconns. Set CONN to a valid connection name, and irisconns will attempt to open the specified connection by default.

InterSystems External Languages Contest: .Net, Java, Python, JavaScript - 2025

irisconns was originally created/published for the InterSystems External Languages Contest: .Net, Java, Python, JavaScript - 2025.

Finding irisconns Files

irisconns looks in the following directories:

  1. Current Directory
  2. Parent Directories
  3. Home Directory

In each directory, irisconns looks for the following files:

  1. irisconns
  2. .irisconns

The first file that contains a section for the given connection name will be loaded. Any missing information will be gathered by prompting the user for more information.

Example irisconns File

# 'default' is the connection returned if no name is provided.
[default]
hostname = localhost
port = 11972
namespace = USER
username = _SYSTEM

This connection name is "TEST".

[TEST]
hostname = test-server
port = 1972
namespace = USER
username = _SYSTEM
confirm = false

This connection name is "PROD".

[PROD]
hostname = prod-server
port = 1972
namespace = %SYS
username = _SYSTEM

irisconns Keys

The following keys can be set for each connection in an irisconns file. Any missing/required keys will be prompted to the user.

Key Description Example Values
hostname Server name/IP of the connection
port Port number for the connection
namespace Namespace being connected to
username User name
confirm Should we confirm passwords? false, no, off, f, n, 0,
true, yes, on, t, y, 1

Environment Variables

If you set the CONN environment variable to a valid connection name, irisconns will try to use that name, by default.

For instance, if CONN is not set, irisconns will look for a configuration named default in all of the found irisconns (and .irisconns) files. If CONN=PROD, irisconns would look for a configuration named PROD when no explicit configuration name if passed in the code.

# Python Environment Variable Example:
# shell> CONN="TEST" python3 test.py

This looks for a configuration named 'default', unless 'CONN' is set.

If CONN="TEST", this looks for a 'TEST' configuration.

irispy = irisconns.get_irispy()

This call to get_irispy will always look for a configuration named 'PROD',

no matter what 'CONN' is set to.

irispy = irisconns.get_irispy('PROD')

// JavaScript Environment Variable Example:
// shell> CONN="TEST" node test.js

// This looks for a configuration named 'default', unless 'CONN' is set.
// If CONN="TEST", this looks for a 'TEST' configuration.
const iris = await irisconns.get_iris();

// This call to get_iris will always look for a configuration named 'PROD',
// no matter what 'CONN' is set to.
const iris = await irisconns.get_iris('PROD');

Python - Installation and Example

Save irisconns.py to your PYTHONPATH so that you can import the irisconns module.

This module requires the IRIS Python SDK:

pip install intersystems-irispython

Example usage:

import irisconns

default connection

irispy = irisconns.get_irispy()

named connection

irispy = irisconns.get_irispy('TEST')

usage

irispy.set('hello world!', 'test', 1)
print(f'>>> Value from IRIS: {irispy.get("test", 1)}')
irispy.kill('test', 1)

JavaScript - Installation and Example

Save irisconns.js to your project so that you can require the irisconns.js package.

This module requires the IRIS JavaScript SDK:

npm install @intersystems/intersystems-iris-native

Example usage:

// Import the package
const irisconns = require('./irisconns.js');

// Wrap in an async function so we can await the connection...
(async () => {
// 'default' connection
const iris = await irisconns.get_iris();

// named (i.e. "PROD") connection
// const iris = await irisconns.get_iris('PROD');

// usage
iris.set('hello world!','test',1);
console.log('>>> Value from IRIS: ', iris.get('test',1));
iris.kill('test',1);
})()

Demo

To demo irisconns, run the following docker compose command to start up a generic IRIS instance and build the demo images:

docker compose up

To run the python demo:

docker run -it --rm --network irisconns_default irisconns-irispy python demo.py

To run the nodejs demo:

docker run -it --rm --network irisconns_default irisconns-irisjs node demo.js
Made with
Version
0.1.106 Oct, 2025
Ideas portal
Category
Developer Environment
Works with
InterSystems IRIS
First published
05 Oct, 2025
Last edited
07 Oct, 2025
Last checked by moderator
08 Oct, 2025Works