From 67bdfd15e84f7226f08d6627ae27a0ba81ba1c41 Mon Sep 17 00:00:00 2001 From: Dmitry Maslennikov Date: Thu, 14 Dec 2023 17:34:37 +0400 Subject: [PATCH] demo Jupiter Notebook added --- .gitignore | 3 +- iris.ipynb | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 iris.ipynb diff --git a/.gitignore b/.gitignore index 72f0592..a1b00a8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ env .pytest_cache build dist -*.egg-info \ No newline at end of file +*.egg-info +__pycache__ diff --git a/iris.ipynb b/iris.ipynb new file mode 100644 index 0000000..b2e0b92 --- /dev/null +++ b/iris.ipynb @@ -0,0 +1,106 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install testcontainers-iris\n", + "!pip install sqlalchemy-iris" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Pulling image containers.intersystems.com/intersystems/iris-community:2023.3\n", + "Container started: 1d5baa884e0d\n", + "Waiting to be ready...\n", + "Waiting to be ready...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "SQLAlchemy URL iris://demo:demo@localhost:65126/demo\n", + "Management Portal http://localhost:65127/csp/sys/UtilHome.csp\n", + "Username demo\n", + "Password demo\n" + ] + } + ], + "source": [ + "from testcontainers.iris import IRISContainer\n", + "\n", + "container = IRISContainer('containers.intersystems.com/intersystems/iris-community:2023.3', username=\"demo\", password=\"demo\", namespace=\"demo\")\n", + "container.with_exposed_ports(1972, 52773)\n", + "container.start()\n", + "print('SQLAlchemy URL', container.get_connection_url())\n", + "portal_url = f'http://localhost:{container.get_exposed_port(52773)}/csp/sys/UtilHome.csp'\n", + "print('Management Portal', portal_url)\n", + "print('Username', container.username)\n", + "print('Password', container.password)" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Waiting to be ready...\n" + ] + }, + { + "data": { + "text/plain": [ + "[('IRIS for UNIX (Ubuntu Server LTS for ARM64 Containers) 2023.3 (Build 254U) Wed Nov 8 2023 13:04:07 EST', 'demo', 'DEMO')]" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sqlalchemy import create_engine, text\n", + "engine = create_engine(container.get_connection_url())\n", + "\n", + "conn = engine.connect()\n", + "res = conn.execute(text(\"select $zversion, $username, $namespace\"))\n", + "res.fetchall()\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.4" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}