How to Install PostgREST in Microsoft Windows

Posted on

How to Install PostgREST in Microsoft Windows

The process for installing PostgREST is the main topic of this article. So, it will focus on how to install PostgREST tool in a host or a device either local or remote. For that purpose, it will use a host or device which has Microsoft Windows as its operating system. So, the process for installing PostgREST tool in this article will use a device where it uses an operating system of Microsoft Windows. There are are specific description about PostgREST in this link. Basically, in that link PostgREST is a standalone web server that turns your PostgreSQL database directly into a RESTful API. Moreover, the structural constraints and permissions in the database determine the API endpoints and operations.

Table of Contents

Introduction

Since the content for the article will be the PostgREST installation, just perform several steps for a necessary preparations. That preparations actually are important which are the requirements in order to be able to install PostgREST tool. In that case, below are steps which is important for preparing those requirements before going on installing PostgREST in it. Just perform below steps before executing how to install PostgREST in Microsoft Windows as follows :

  1. As for the first step to fulfill the requirements, just prepare an available Power Shell tool. So, just run the Power Shell tool by executing it or run it normally. Basically, a Windows Shortcut+R will have an available text field for inserting a text to execute the command. Just type ‘powershell’ and apparently, the Power Shell tool will appear in an instant.

  2. The next step after the Power Shell tool appear, it is actually a command for installing type a certain command in order to set a certain parameter for setting up the Power Shell environment. That is a command for enabling the process for further installation.

    PS C:\Users\Personal> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
    
    Execution Policy Chang
    The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
    you to the security risks described in the about_Execution_Policies help topic at
    https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
    [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):

    For the above process, just type ‘Y’ in order to allow executing a certain command.

    [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y
    PS C:\Users\Personal>
    
  3. After executing the above command in order to permit further process, just do a certain command which is for installing an additional tool. That tool is important as requirement before installing ‘PostgREST’. That tool is a tool with the name of ‘Scoop’. Actually, there is an article to show how to install ‘Scoop’. That article is available in ‘How to Install Scoop in Microsoft Windows‘. For installing ‘Scoop’ directly, just perform the following command :

    PS C:\Users\Personal> iwr -useb get.scoop.sh | iex
    Initializing...
    Downloading...
    Extracting...
    Creating shim...
    Adding ~\scoop\shims to your path.
    Scoop was installed successfully!
    Type 'scoop help' for instructions.
    PS C:\Users\Personal>

Install PostgREST in Microsoft Windows

After finishing on installing the necessary requirement which is the installation of PostgREST, just continue on the process. That is the process for installing PostgREST still in the Power Shell tool as follows :

  1. As for the first step, just use the previous Power Shell tool which has already set with an additional setting for permitting specific environment condition. If it does not running anymore, just run the Power Shell once more and type the command for permitting further installation process.

  2. After that, just execute the following command using ‘Scoop’ to install PostgREST as follows :

    Windows PowerShell
    Copyright (C) Microsoft Corporation. All rights reserved.
    Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
    PS C:\Users\Personal> scoop install postgrest Updating Scoop... Updating 'main' bucket... Converting 'main' bucket to git repo...
    Checking repo... OK
    The main bucket was added successfully.
    Updating 'snyk' bucket...
    * 945cc35 Upgraded to latest Snyk version skip-checks: true 2 days ago
    * e81283e Upgraded to latest Snyk version skip-checks: true 3 days ago
    Scoop was updated successfully!
    Installing 'postgrest' (10.1.2) [64bit] from main bucket
    postgrest-v10.1.2-windows-x64.zip (11.8 MB) [=================================================================] 100%
    Checking hash of postgrest-v10.1.2-windows-x64.zip ... ok.
    Extracting postgrest-v10.1.2-windows-x64.zip ... done.
    Linking ~\scoop\apps\postgrest\current => ~\scoop\apps\postgrest\10.1.2
    Creating shim for 'postgrest'.
    'postgrest' (10.1.2) was installed successfully!
    'postgrest' suggests installing 'postgresql'.
    PS C:\Users\Personal>

    Test PostgREST in Microsoft Windows

    Finally, in the last part, just test it after the installation of PostgREST in the previous part is a success. Just use the Power Tool from the previous part or a normal Command Line Interface available such as Command Prompt as follows :

    Microsoft Windows [Version 10.0.22621.1265]
    (c) Microsoft Corporation. All rights reserved.
    
    C:\Users\Personal>postgrest
    26/Feb/2023:08:53:37 +0700: Attempting to connect to the database...
    26/Feb/2023:08:53:37 +0700: {"code":"PGRST000","details":"connection to server at \"localhost\" (::1), port 5432 failed: fe_sendauth: no password supplied\n","hint":null,"message":"Database connection error. Retrying the connection."}
    26/Feb/2023:08:53:37 +0700: Attempting to reconnect to the database in 0 seconds...
    26/Feb/2023:08:53:38 +0700: {"code":"PGRST000","details":"connection to server at \"localhost\" (::1), port 5432 failed: fe_sendauth: no password supplied\n","hint":null,"message":"Database connection error. Retrying the connection."}
    26/Feb/2023:08:53:38 +0700: Attempting to reconnect to the database in 1 seconds...
    26/Feb/2023:08:53:40 +0700: {"code":"PGRST000","details":"connection to server at \"localhost\" (::1), port 5432 failed: fe_sendauth: no password supplied\n","hint":null,"message":"Database connection error. Retrying the connection."}
    26/Feb/2023:08:53:40 +0700: Attempting to reconnect to the database in 2 seconds...
    26/Feb/2023:08:53:44 +0700: {"code":"PGRST000","details":"connection to server at \"localhost\" (::1), port 5432 failed: fe_sendauth: no password supplied\n","hint":null,"message":"Database connection error. Retrying the connection."}
    26/Feb/2023:08:53:44 +0700: Attempting to reconnect to the database in 4 seconds...
    26/Feb/2023:08:53:52 +0700: {"code":"PGRST000","details":"connection to server at \"localhost\" (::1), port 5432 failed: fe_sendauth: no password supplied\n","hint":null,"message":"Database connection error. Retrying the connection."}
    26/Feb/2023:08:53:52 +0700: Attempting to reconnect to the database in 8 seconds...
    26/Feb/2023:08:54:09 +0700: {"code":"PGRST000","details":"connection to server at \"localhost\" (::1), port 5432 failed: fe_sendauth: no password supplied\n","hint":null,"message":"Database connection error. Retrying the connection."}
    26/Feb/2023:08:54:09 +0700: Attempting to reconnect to the database in 16 seconds...
    
    C:\Users\Personal>
    

    Apparently, looking at the above output, although it ends in a failure, the command ‘PostgREST’ representing tool is actually running. In that case, the installation process of ‘PostgREST’ tool is a success.

Leave a Reply