No Result
View All Result
DevRescue
  • Home
  • Python
  • Lists
  • Movies
  • Finance
  • Opinion
  • About
  • Contact Us
  • Home
  • Python
  • Lists
  • Movies
  • Finance
  • Opinion
  • About
  • Contact Us
DevRescue
Home Blog Tools

Build An Admin Panel in Retool with SQL Server 2022 Database

by Khaleel O.
October 12, 2022
in Tools
Reading Time: 13 mins read
A A
Build An Admin Panel in Retool with SQL Server Database
Build An Admin Panel in Retool with SQL Server Database

In this article you will learn how to build an Admin Panel in Retool with a SQL Server 2022 Database backend.

Microsoft SQL Server also known as MS SQL Server or simply as MSSQL, is a relational database management system (RDBMS). Beginning its life in the late 1980s, it has grown to become one of the world’s most popular and trusted database solutions for large scale enterprise use. It now features a range of supporting services beyond the traditional RDBMS including machine learning, high availability, analytics, enhanced security and performance and more in both on-premises and cloud implementations. The latest release of MSSQL, SQL Server 2022, is in the preview stage as of this writing.

Retool is a platform that provides components and controls for rapid development of internal tools with rich user experiences. Internal tools such as Admin Panels are what empower operators, administrators, analysts, managers and executive staff to manage data and system configurations, monitor real-time operations or perform any other critical administrative function.

In this article you will connect Retool to a SQL Server 2022 instance and build an Admin Panel using Retool forms and GUI components to perform CRUD (create, read, update and delete) operations on some sample data.

You will proceed in the following sequence:

– Acquire the Prerequisites

– Provision Ubuntu VM On Google Cloud with SQL Server 2022 running in a Docker Container

– Load Sample Data into SQL Server 2022 instance

– Build out Retool Admin Panel

Prerequisites

You will need to set up the following before moving forward:

– Google Cloud Platform (GCP) Account

– Retool Account

GCP Account Setup and VM Provisioning for SQL Server 2022 Instance

You will require a GCP account to provision your SQL Server 2022 (Preview) instance. Specifically, you will launch an instance of SQL Server as a Docker Container on the Ubuntu 20.04 LTS operating system.

There are many ways you can provision SQL Server using other cloud providers such as AWS and Microsoft Azure but for this article GCP will be used. Also, because of the SQL Server System Requirements for disk space and memory, finding a completely Free Tier with these specs on any of these platforms would prove difficult.

Fortunately, GCP has a free trial offer for customers that meet the eligibility criteria. The trial runs for a 90-day period that includes USD $300 worth of free Cloud Billing credits. This offer should be more than sufficient to complete the example in this article and perform any other experiments you may have planned on GCP.

You will require a free Google Account to sign in to GCP and claim the free credits, if you don’t already have one. Once you have signed up and logged into the GCP console you then need to create a Linux VM instance on the Compute Engine. The exact steps will be detailed in the GCP guide but the broad steps are as follows:

1. Create a Google Cloud project.

2. Enable the Compute Engine API to allow VMs to be created.

3. Create a Linux VM running the Ubuntu 20.04 LTS operating system.

The GCP guide will list all individual steps:

admin panel retool sql server 2022 - create new linux vm on google cloud
create new linux vm on google cloud

Alternatively the GCP guide gives you the option of the assisted setup which may be a bit easier and faster:

admin panel retool sql server 2022 - assisted vm setup on google cloud
assisted vm setup on google cloud

Step 1 and 2 are both straightforward and simple. For this article, the most important is step 3, the creation of the VM, because the requirements here are specific. When you click the Go to Create an instance button to launch the VM setup or proceed through the assisted setup to the Create a Linux VM instance step, you will be asked to provide details for the VM to be created:

enter vm details on gcp
enter vm details on gcp

You will now fill in the following details:

– Fill in the instance `Name` with a suitable identifier for the VM and select a `Region` and `Zone` closest to you.

– In the `Machine Configuration Section`, select the `General-Purpose` Machine Family, then select `E2` under `Series` and `e2-medium` under `Machine type`. The e2-medium machine type with its 4GB and 2 vCPUs is more than sufficient to run MSSQL.

– Under the very important `Boot Disk` section click the `CHANGE` button which should launch another window. In this new window be sure to select `Ubuntu` for the `Operating System`, `Ubuntu 20.04 LTS` for the `Version` and `Balanced Persistent Disk` for the `Boot Disk Type`. Enter a value of 10 or higher for the `Size (GB)` because MSSQL requires a minimum of 6GB available hard-disk space.

Select OS Type
Select OS Type

– Next, check `Allow HTTP traffic` under the `Firewall` section.

– Every other setting here is fine with the default values. When you are ready to proceed click `CREATE` to begin the VM creation.

When the VM creation is complete you should be redirected to or receive a link to the `VM Instances` page. If not, it may be found by using the left navigation menu, going to `Compute Engine` and then `VM Instances` under the `VIRTUAL MACHINES` section. You should see the newly created VM:

vm instances on GCP
vm instances on GCP

Remember the `External IP` value. This is address that will be used to connect to the SQL instance on the VM.

When you launch a new SSH session in a new browser window, you should see the following at the terminal. This means you successfully provisioned the VM:

Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.15.0-1017-gcp x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue Sep 27 06:57:44 UTC 2022

...

New release '22.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Mon Sep 26 22:52:17 2022 from XX.XXX.XXX.XX
user@vmname:~$

This is the terminal where you will issue commands to set up Docker and the SQL container.

The next step would be to set up the MSSQL 2022 Docker container, which will be covered in an upcoming section.

Create a Retool Account

The Admin Panel in Retool with a SQL Server 2022 database will be build in the cloud. This applies to both the database and the admin panel. Navigate to the official Retool website. You should see one button on the upper right hand corner called `Start for free` or near the middle of the page called `Try Retool for free`, either one will take you to the sign up form:

retool sign up
retool sign up

After you enter your details and click `Sign up` or if you choose to `Sign up with Google`, you will be taken to another page to create your Retool workspace which is required to sign in to Retool:

create retool workspace
create retool workspace

Set up SQL Server 2022 Docker Container instance

Now that the VM is up and running, you must now install the Docker engine. Docker is a popular system used to containerize applications. Containers are self contained executable packages that contain an application and all its dependencies.

The full guide to install Docker engine on Ubuntu contains all of the instructions and terminal commands to get Docker installed and running.

Once Docker is up on the VM, you must now download the free SQL Server 2022 preview container from the official DockerHub repo. You can do this with the following terminal command:

sudo docker pull mcr.microsoft.com/mssql/server:2022-latest

The identifier `mcr.microsoft.com/mssql/server` is the container image and `2022-latest` is the tag for the specific SQL version. After the container image is downloaded, issuing a `docker images` command at the terminal to view all container images will return something similar to the following:

username@vmname:~$ sudo docker images
REPOSITORY                       TAG           IMAGE ID       CREATED         SIZE
mcr.microsoft.com/mssql/server   2022-latest   97XXXXXXXXX   5 weeks ago     1.6GB
mcr.microsoft.com/mssql/server   2019-latest   e3XXXXXXXXX   2 months ago    1.47GB
hello-world                      latest        feXXXXXXXXX   12 months ago   13.3kB

Next, you will issue the `docker run` command to start the container:

sudo docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=XXXXXXXXXX" \
   -p 1433:1433 --name container_name --hostname vm_name \
   -d \
   mcr.microsoft.com/mssql/server:2022-latest

The `-e` option is used to set two mandatory environment variables for the container: the EULA agreement and the SA Password. The `ACCEPT_EULA` variable must always be `Y` and the `MSSQL_SA_PASSWORD` is the SQL SA password and it must be set to a reasonably strong value because it has full permissions to all databases on the SQL instance. Also be sure to remember the password you use here for later.

The `-p` option binds port 1433 of the host to port 1433 of the container. Because this is a SQL Server container the standard SQL Server port for connections is used.

The `–name` option is the custom name for the container.

The `–hostname` option is the host name of the container or the name you give to the VM when you first set it up.

The option `-d` runs the container in the background and prints only the container ID.

When the above command executes successfully the first time, the Container ID should be returned in the terminal. Issuing the following `docker ps -a` commmand should show all running containers:

username@vmname:~$ sudo docker ps -a
CONTAINER ID  IMAGE                                      ... PORTS                                      NAMES
74XXXXXXXXX   mcr.microsoft.com/mssql/server:2022-latest ... 0.0.0.0:1433->1433/tcp, :::1433->1433/tcp  containername

As expected, the container is using port 1433 which would allow you to connect to it remotely if the firewall allows.

On subsequent occasions, you only need to run the `sudo docker start <container_id>` command to start the container from a stopped state and the `sudo docker stop <container_id>` to stop it.

To connect to this instance, database and data from your desktop or Retool you will need to create a new firewall rule in GCP. To do this, navigate back to the GCP console to the `VM instances` page from earlier. There is a search bar at the top where you will enter the word `firewall`. The search should return in its results `Firewall VPC Network` under the Products and Pages section, click it:

GCP VM Firewall
GCP VM Firewall

Then when the Firewall page comes up click `CREATE FIREWALL RULE` to create a new firewall rule:

Create Firewall Rule
Create Firewall Rule

You will now fill in the form details of this new rule. Give it a suitable `Name` and `Description`. Next, ensure that `Source Filter` has `IPv4 ranges` selected. Finally under `Protocols and Ports` the `Specified protocols and ports` radio button is selected, check the `TCP` box and enter port number `1433` as the port number. Everything else retains default settings, then you click `CREATE` to create the rule. If you navigate back to the `Firewall` page you should see the new rule in the list of rules under the `VPC firewall rules` section:

all GCP firewall rules
all GCP firewall rules

Recall that port 1433 was used because that was the VM port that was mapped to the container port 1433 and also because it is the standard SQL port for incoming connections.

Leave the other firewall rules as they are. They should be sufficient to allow Retool to connect to the SQL instance on the VM when the time comes.

Now that the SQL instance is up and running you can try connecting! Remember that `External IP` from earlier and the SA password? You will now use both to test the connection to the SQL instance.

There are many ways you can connect to the instance but using the SSMS tool is one of the most popular. Download and install the SSMS tool to your desktop if you haven’t already done so. Then open up a new connection by navigating to `File` and then `Connect Object Explorer…` in the top menu bar. This will open up a new window where you will enter the connection information:

Connect to SQL Instance on VM
Connect to SQL Instance on VM

The Server Name value will be the `External IP` for the Ubuntu VM on GCP. The Authentication method will be SQL Server Authentication. The Login will be simply sa and the password will be the password that you supplied for the `MSSQL_SA_PASSWORD` environment variable when you created the docker container. If all goes well, clicking Connect should connect you to the SQL instance on the VM and you should see it in the Object Explorer of the SSMS tool:

SQL Instance in Object Explorer

The next step would now be to load the sample data into a new database on this instance which you will do in the next section. Click here to proceed to PART 2 of this tutorial on building an Admin Panel with Retool on SQL Server 2022. See you there!

Tags: cloudcontainerdockergcpgoogle cloud platformjavascriptms sqlmssqlretoolsql server
Previous Post

Python AES CBC Decrypt Example

Next Post

Build An Admin Panel in Retool with SQL Server 2022 Part 2

Khaleel O.

Khaleel O.

I love to share, educate and help developers. I have 14+ years experience in IT. Currently transitioning from Systems Administration to DevOps. Avid reader, intellectual and dreamer. Enter Freely, Go safely, And leave something of the happiness you bring.

Related Posts

Tools

Build An Admin Panel in Retool with SQL Server 2022 Part 2

by Khaleel O.
October 12, 2022
0
0

Be sure to check out PART 1 of our tutorial before you proceed. Next you will load Sample Data into...

Read moreDetails

DevRescue © 2021 All Rights Reserved. Privacy Policy. Cookie Policy

Manage your privacy

To provide the best experiences, we and our partners use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us and our partners to process personal data such as browsing behavior or unique IDs on this site and show (non-) personalized ads. Not consenting or withdrawing consent, may adversely affect certain features and functions.

Click below to consent to the above or make granular choices. Your choices will be applied to this site only. You can change your settings at any time, including withdrawing your consent, by using the toggles on the Cookie Policy, or by clicking on the manage consent button at the bottom of the screen.

Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Statistics

Marketing

Features
Always active

Always active
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
Manage options
{title} {title} {title}
Manage your privacy
To provide the best experiences, DevRescue.com will use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Statistics

Marketing

Features
Always active

Always active
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
Manage options
{title} {title} {title}
No Result
View All Result
  • Home
  • Python
  • Lists
  • Movies
  • Finance
  • Opinion
  • About
  • Contact Us

DevRescue © 2022 All Rights Reserved Privacy Policy