Home Applications isc-cloud-sql-python-demo

isc-cloud-sql-python-demo

This application is not supported by InterSystems Corporation. Please be notified that you use it at your own risk.
5
1 reviews
0
Awards
189
Views
0
IPM installs
1
0
Details
Releases
Reviews
Issues
Pull requests
This app has a demo View
A simple python and flask app with IRIS Cloud SQL on back

What's new in this version

added insert records form

isc-cloud-sql-python-demo

This is an example of a very simple python-flask application, which works with InterSystems IRIS Cloud SQL server.

Prerequisits

I consider you deployed InterSystems Cloud SQL and have the name of the host and password for SQLAdmin user.
You should have git installed locally. If not, here is where you can make it.
you should have Python3 installed locally. Here is how to install if not.

Running app locally

  1. Git clone the repository.
  2. Create venv:
    Open terminal in the repository folder and call:
$ python3 -m venv venv
$ source venv/bin/activate
  1. Install python libs
    Run the command below to install packages listed in requirements.txt
$ python3 -m pip install -r requirements.txt
  1. Init local environment variables:
$ echo "HOST=your_iris_cloud_sql_host_name" > .env
$ echo "IRIS_USERNAME=SQLAdmin" >> .env
$ echo "IRIS_PASSWORD=password" >> .env

Port is hardcoded to 1972 and namespace is hardcoded to “USER” in this demo.
5. Let’s create a few records!
Run init_db.py to connect, create a table and add two records:

$ python3 init_db.py

Let’s check if there are records in the database. Connect to the server via irissqlcli:
irissqlcli -h iris_cloud_sql_host -p 1972 -u SQLAdmin -n USER -W
Should be something like that:

$[SQL]server:USER> select * from books
+----+----------------------+-----------------+-----------+------------------------+---------------------+
| id | title                | author          | pages_num | review                 | date_added          |
+----+----------------------+-----------------+-----------+------------------------+---------------------+
| 1  | A Tale of Two Cities | Charles Dickens | 489       | A great classic!       | 2023-03-21 16:40:19 |
| 2  | Anna Karenina        | Leo Tolstoy     | 864       | Another great classic! | 2023-03-21 16:40:19 |
+----+----------------------+-----------------+-----------+------------------------+---------------------+
2 rows in set
Time: 0.186s
  1. Let’s run flask app.
    First let’s turn on debug mode. Call in the terminal:

export FLASK_APP=app
export FLASK_ENV=development

$ flask run
Open in browser: http://127.0.0.1:5000/
You should see the small web app listing this two records.

  1. Deploying the app to Heroku.
    TBD
Read more
Made with
Version
1.1.023 Mar, 2023
Category
Technology Example
Works with
InterSystems IRIS
First published
22 Mar, 2023