Пример #1
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        conn = irisnative.createConnection(self.host, self.port,
                                           self.namespace, self.user,
                                           self.password)
        self.iris = irisnative.createIris(conn)
Пример #2
0
def get_iris_object():
    # Create connection to InterSystems IRIS
    connection = irisnative.createConnection('iris', 51773, 'IRISAPP',
                                             '_SYSTEM', 'SYS')

    # Create an iris object
    return irisnative.createIris(connection)
def run():
    # Retrieve connection information from configuration file
    connection_detail = get_connection_info("connection.config")

    ip = connection_detail["ip"]
    port = int(connection_detail["port"])
    namespace = connection_detail["namespace"]
    username = connection_detail["username"]
    password = connection_detail["password"]

    # Create connection to InterSystems IRIS
    connection = irisnative.createConnection(ip, port, namespace, username,
                                             password)
    print("Connected to InterSystems IRIS")

    # Create an iris object
    iris_native = irisnative.createIris(connection)

    # Starting interactive prompt
    while True:
        print("1. Test")
        print("2. Store stock data")
        print("3. View stock data")
        print("4. Generate Trades")
        print("5. Call routines")
        print("6. Quit")
        selection = int(input("What would you like to do? "))
        if selection == 6:
            break
        elif selection not in range(1, 7):
            print("Invalid option. Try again!")
            continue
        execute_selection(selection, iris_native)
    def get_iris_connection(self, iris_config):
        #todo: understand the behavior of connection object and implement the correct way
        if not self.iris_connection:
            self.iris_connection = irisnative.createConnection(
                iris_config["host"], iris_config["port"],
                iris_config["namespace"], iris_config["username"],
                iris_config["password"])

        return self.iris_connection
Пример #5
0
    def get_iris_native(self):
        #todo: understand the behavior of connection object and implement the correct way
        if not self.iris_connection:
            self.iris_connection = irisnative.createConnection(
                self.iris_config["host"], self.iris_config["port"],
                self.iris_config["namespace"], self.iris_config["username"],
                self.iris_config["password"])

        print("Connected to InterSystems IRIS")
        # Create an iris object
        self.iris_native = irisnative.createIris(self.iris_connection)
        return self.iris_native
Пример #6
0
def connect_database():
    connection_info = get_connnection_info(CONFIG_FILE)
    ip = connection_info['ip']
    port = int(connection_info['port'])
    namespace = connection_info['namespace']
    username = connection_info['username']
    password = connection_info['password']

    connection = irisnative.createConnection(ip, port, namespace, username,
                                             password)

    print("Connected to server")
    return irisnative.createIris(connection)
Пример #7
0
def getIris():
    global __IRIS_CONN, __IRIS
    if "__IRIS" in globals():
        return __IRIS

    __IRIS_CONN = irisnative.createConnection(config.IRIS_IP, config.IRIS_PORT,
                                              config.IRIS_NAMESPACE,
                                              config.IRIS_USER,
                                              config.IRIS_PASSWORD)
    __IRIS = irisnative.createIris(__IRIS_CONN)

    atexit.register(__IRIS_CONN.close)

    return __IRIS
Пример #8
0
def demoSkinnyJwt(verticalType, classId, objectId):
    # Modify connection info based on your environment

    ip = "trak.australiasoutheast.cloudapp.azure.com"
    port = 1972
    namespace = "PASS"
    username = "******"
    password = "******"

    # create database connection and IRIS instance
    connection = irisnative.createConnection(ip, port, namespace, username,
                                             password)
    dbnative = irisnative.createIris(connection)

    print("Generates a signed skinny JWT.")
    Globalname = dbnative.get("name")
    Globalmrn = dbnative.get("mrn")
    Globalemail = dbnative.get("email")
    Globaldate = dbnative.get("date")
    Globaldoctor = dbnative.get("doctor")
    Globalhospital = dbnative.get("hospital")
    Globalhospitalphone = dbnative.get("hospitalphone")
    Globalhospitaladdress = dbnative.get("hospitaladdress")
    Globallocation = dbnative.get("location")
    Globalservice = dbnative.get("service")

    skinnyJwt = services.makeSkinnyJwt(verticalType, classId, objectId,
                                       Globalname, Globalmrn, Globaldate,
                                       Globaldoctor, Globalhospital,
                                       Globalhospitalphone,
                                       Globalhospitaladdress, Globallocation,
                                       Globalservice)

    if skinnyJwt is not None:
        print('This is an "skinny" jwt:\n%s\n' % (skinnyJwt.decode('UTF-8')))
        print(
            'you can decode it with a tool to see the unsigned JWT representation:\n%s\n'
            % ('https://jwt.io'))

        print("[1. Setting and getting a global]")

        dbnative.set(SAVE_LINK + skinnyJwt.decode('UTF-8'), "PassLink")
        Globallink = dbnative.get("PassLink")

        print("The value of testglobal is ", Globallink)

    return
Пример #9
0
def run():
    # Credentials to connect to InterSystems IRIS database
    ip = "localhost"
    port = 51773
    namespace = "USER"
    username = "******"
    password = "******"

    # Make connection to InterSystems IRIS database
    connection = irisnative.createConnection(ip, port, namespace, username,
                                             password)
    print("Hello World! You have successfully connected to InterSystems IRIS.")

    # Create an InterSystems IRIS native object
    iris_native = irisnative.createIris(connection)

    # Store data natively into a global using the InterSystems IRIS native object
    iris_native.set(8888, "^testglobal", "1")
    global_value = iris_native.get("^testglobal", "1")
    print("The value of ^testglobal(1) is {}".format(global_value))
def connect_to_iris():
    # Login credentials
    driver = "{InterSystems ODBC}"
    ip = "localhost"
    port = 51773
    namespace = "USER"
    username = "******"
    password = "******"

    # Connect to InterSystems IRIS using PyODBC
    connection_string = 'DRIVER={};SERVER={};PORT={};DATABASE={};UID={};PWD={}'\
        .format(driver, ip, port, namespace, username, password)
    pyodbc_connection = pyodbc.connect(connection_string)

    # Connect to InterSystems IRIS using the Native API
    nativeapi_connection = irisnative.createConnection(ip, port, namespace,
                                                       username, password)

    print("Connected to InterSystem IRIS")
    return pyodbc_connection, nativeapi_connection
Пример #11
0
import irisnative

# Modify connection info based on your environment
ip = "iris"
port = 51773
namespace = "USER"
username = "******"
password = "******"

# create database connection and IRIS instance
connection = irisnative.createConnection(ip, port, namespace, username,
                                         password)
dbnative = irisnative.createIris(connection)

print("[1. Setting and getting a global]")
# setting and getting a global
# ObjectScript equivalent: set ^testglobal("1") = 8888
dbnative.set(8881, "testglobal", "1")
dbnative.set(8821, "testglobal", "2", "21")
dbnative.set(8822, "testglobal", "2", "22")
dbnative.set(8831, "testglobal", "3", "31")
dbnative.set(8832, "testglobal", "3", "32")
dbnative.set(8833, "testglobal", "3", "33")

# ObjectScript equivalent: set globalValue = $get(^testglobal("1"))
globalValue = dbnative.get("testglobal", "1")

print("The value of testglobal is ", globalValue)
print()

print("[2 Iterating over a global]")
import getpass
import irisnative

user = input("IRIS user: "******"IRIS password: "******"127.0.0.1", 51773, "USER", user, password)
iris = irisnative.createIris(conn)

stop_id = None

stop_name = "Silver Ave & Holyoke St"
stop_id = iris.get("stopnames", stop_name)
if stop_id is None:
    print("Stop not found.")
    import sys
    sys.exit()

all_stop_times = set()

trips = iris.iterator("stoptimes", stop_id).subscripts()
for trip in trips:
    all_stop_times.update(iris.iterator("stoptimes", stop_id, trip).values())

for stop_time in sorted(all_stop_times):
    print(stop_time)

conn.close()
#InterSystems IRIS の Python Native APIを使ってみよう
######################################
#[1] irisnative パッケージのインポート
#[2] IRISに接続+IRISオブジェクトの作成
#[3] ^employee(1)="田口" の作成
#[4] [3]で設定した値の取得
#[5] ^employee(2)="秋山" の作成
#[6] 全件取得
#[7] ^employee(1)の削除
######################################

#[1] irisnative パッケージのインポート
import irisnative
#[2]IRISに接続+IRISオブジェクトの作成
connection = irisnative.createConnection("localhost", 51773, "user", "_system",
                                         "SYS")
iris_native = irisnative.createIris(connection)

#[3] ^employee(1)="田口"の作成
iris_native.set("田口", "employee", 1)

#[4] [3]で作成した ^employee(1)の取得
print(iris_native.get("employee", 1))

#[5] ^employee(2)="秋山" の作成
iris_native.set("秋山", "employee", 2)

#[6] 全件取得
for key, value in iris_native.iterator("employee"):
    print(key, "-", value)
    for target in nodelist:
        #ラベル表示用のデータ取得
        labellist[target] = iris_native.get("Relation", target)
        getRelation(target, graph, count + 1)


#[2]IRISに接続+IRISオブジェクトの作成

# 接続ホスト名を環境変数から取得。ない場合は localhost
host = os.environ.get('IRISHOSTNAME')

if host == None:
    host = "localhost"

connection = irisnative.createConnection(host, 1972, "user", "_system", "SYS")
iris_native = irisnative.createIris(connection)

#[3] 登場人物の登録
#   set ^Relation("Eren")="主人公(エレン)
iris_native.set("主人公\n(エレン)", "Relation", "Eren")
iris_native.set("エレンの幼馴染\n(アルミン)", "Relation", "Armin")
iris_native.set("エレンの幼馴染\n(ミカサ)", "Relation", "Mikasa")
iris_native.set("エレンのお父さん\n(グリシャ)", "Relation", "Grisha")
iris_native.set("エレンの異母兄弟\n(ジーク)", "Relation", "Zeke")
iris_native.set("鎧の巨人\n(ライナー)", "Relation", "Reiner")
iris_native.set("超大型の巨人\n(ベルトルト)", "Relation", "Bertolt")
iris_native.set("エレンのお母さん(カルラ)\nダイナに捕食", "Relation", "Carla")
iris_native.set("ジークのお母さん(ダイナ)\nレイス王家[フリッツ家]", "Relation", "Dina")
iris_native.set("人類最強の兵士\n(リヴァイ)", "Relation", "Levi")
Пример #15
0
    button2 = app.config['VOTE2VALUE']

if ("TITLE" in os.environ and os.environ['TITLE']):
    title = os.environ['TITLE']
else:
    title = app.config['TITLE']

# Redis configurations
redis_server = os.environ['REDIS']

# Redis Connection
try:
    if "REDIS_PWD" in os.environ:
        connection = irisnative.createConnection(
            hostname=redis_server,
            port=1972,
            namespace='USER',
            username='******',
            password=os.environ['IRIS_PWD'])
    else:
        connection = irisnative.createConnection(hostname=redis_server,
                                                 port=1972,
                                                 namespace='USER',
                                                 username='******',
                                                 password='******')
    r = irisnative.createIris(connection)
except:
    exit('Failed to connect to Redis, terminating.')

# Change title to host name to demo NLB
if app.config['SHOWHOST'] == "true":
    title = socket.gethostname()