Skip to content

Commit

Permalink
Update services.qmd
Browse files Browse the repository at this point in the history
  • Loading branch information
brenda-lambert committed Sep 22, 2023
1 parent 22388db commit a5835ad
Showing 1 changed file with 63 additions and 18 deletions.
81 changes: 63 additions & 18 deletions site/services.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,107 @@ editor: visual

<div style="text-align: justify">

Hal9 allows the users to connect and query a database in PostgreSQL. Not only this, but it also gives you the necessary credentials to create your database in this data warehouse.
Hal9 allows the users to connect and query a database in PostgreSQL. In this tutorial, we will see how to create a PostgreSQL database on Heroku, how to connect it to services like Notion using Brackets, and how to configure Hal9 to access our database.

If you prefer a video explanation, we recorded [this video](https://www.youtube.com/watch?v=SiX5p7mD13g) for you. Otherwise, keep reading along.
<br>

### Hal9 Configuration
### Creating a PostgreSQL database on Heroku

The steps configure Hal9 to connect to a PostgreSQL database are:
[Heroku](https://devcenter.heroku.com/) is a platform as a service that enables developers to build, run, and operate applications entirely in the cloud. It also offers a plan for hosting PostgreSQL databases.

- Once you are logged in, you must go to settings and you will notice that the *Enable database support* option is not selected.
In order to create a new database on Heroku, you first need to create an app in your personal dashboard. Then you can attach a Heroku Postgres instance to it as a resource. Let's see how to do this step by step.

To begin, access the Heroku platform by visiting <https://id.heroku.com/login> and entering your login credentials. In case you don't have an account, there is a Sign Up option available beneath the login form.

<center><img src="Images/services1.png" style="max-width: 70%"/></center>
<br>

After accessing your personal app dashboard, proceed to create a new app. If your dashboard is currently vacant, simply click on the "Create new app" button. Alternatively, if your dashboard contains other apps, click on the "New" button located in the top-right corner and select "Create new app".

<center><img src="Images/services2.png" style="max-width: 70%"/></center>
<br>

<center><img src="Images/120.png" style="max-width: 70%"/></center>
To link a PostgreSQL database to the recently created app, go to the Resources tab located in the header of the app dashboard. Proceed to enter "Heroku Postgres" into the search field for Add-ons. From the dropdown list of suggestions, choose the recommended Heroku Postgres add-on.

<center><img src="Images/services3.png" style="max-width: 70%"/></center>
<br>

Congratulations, you now created a PostgreSQL database!

To find the credentials and the connection URL for the PostgreSQL database, you need to navigate to the Resources tab in your app's dashboard again and select the Heroku Postgres resource. This brings you to the configuration screen of the your PostgreSQL database that should look like this:

<center><img src="Images/services4.png" style="max-width: 70%"/></center>
<br>

- When you select it, a *Create* button will appear, which when pressed will give you your Postgres credentials, as it is shown below.
Now in the Settings tab in the header of that screen, you can click the View Credentials button to see the credentials of your PostgreSQL database:

<center><img src="Images/121.png" style="max-width: 70%"/></center>
<center><img src="Images/services5.png" style="max-width: 70%"/></center>
<br>

These credentials give you access to a database in PostgreSQL, which you build by connecting it to other applications where you will extract data from using differents integration frameworks. In case you do not have a technical background, we recommend using [Bracket](https://www.usebracket.com/) for this step.


### Using Bracket

[Bracket](https://docs.usebracket.com/introduction) is a fast, code-optional way to sync data between databases, data warehouses, and SaaS tools and enables you to set up limitlessly flexible one-way or two-way syncs between any pairing of database or SaaS tool. It support differents integrations, for example Google Sheets, Notion, Snowflake, and Postgres.

<center><img src="Images/1.png" style="max-width: 70%"/></center>
<center><img src="Images/1.png" style="max-width: 70%"/></center>
<br>

### Hal9 Configuration

The steps to configure Hal9 to connect to a PostgreSQL database are:

- Once you are logged in, you must go to settings and you will notice that the *Enable database support* option is not selected.

<center><img src="Images/120.png" style="max-width: 70%"/></center>(update this)
<br>

- When you select it, you will need to fill in the connection box, in which you must enter the URI obtained from Heroku, but replacing postgres with postgresql+psycopg2

<center><img src="Images/121.png" style="max-width: 70%"/></center>(update this)
<br>


For example, if our URI is:

`postgres://cwzyrhkleuxkbz:c5b6e987f6667c7e810278ff60885c38647735bbba0477e0c72e5dd3d3cdb56a@ec2-34-236-103-63.compute-1.amazonaws.com:5432/dffrnjllhkeh18`

we will enter:

`postgresql+psycopg2://cwzyrhkleuxkbz:c5b6e987f6667c7e810278ff60885c38647735bbba0477e0c72e5dd3d3cdb56a@ec2-34-236-103-63.compute-1.amazonaws.com:5432/dffrnjllhkeh18`


Once this is done, we select *Validate dataset*, then *ok* and we will be ready to use Hal9 with the data from our Postgres database.

<br>

#### Example: Notion \< Bracket \> Postgres \<\> Hal9
### Example: Notion \< Bracket \> Postgres \<\> Hal9

Once we have the Postgres credentials that Hal9 gives us and a database on Notion, it is very easy to connect them both using Bracket as an intermediary. To do this we will use the [Bracket legacy app](https://legacy.app.usebracket.com/).
Once we have the Postgres credentials and a database on Notion, it is very easy to connect them both using Bracket as an intermediary. To do this we will use the [Bracket legacy app](https://legacy.app.usebracket.com/).

In this app, we select Notion as the main data source and then select the database we want to use. In case you do not have any available database, we must select Link new bases and give permission to Bracket to access them.

<center><img src="Images/122.png" style="max-width: 70%"/></center>
<center><img src="Images/122.png" style="max-width: 70%"/></center>
<br>

Then we select Postgres as the secondary data source and introduce the credentials we obtained from Hal9.

<center><img src="Images/123.png" style="max-width: 70%"/></center>
<center><img src="Images/123.png" style="max-width: 70%"/></center>
<br>

Once this information has been introduced, we can check the connection and if it is successful, we can proceed to the next step, in which we will select the synchronization options.

<center><img src="Images/124.png" style="max-width: 70%"/></center>
<center><img src="Images/124.png" style="max-width: 70%"/></center>
<br>

In the next step, we will review our data, the connection and the mapping established between the two databases. We will also have the option of running a test run where we will not synchronize any data, run a single run where we will only synchronize our data once, or set up the connection and run the synchronization every certain time. With the completion of this step, we will have our data ready in Postgres and these will be accessible from Hal9.

As an example dataset, we use the *startups-hiring-2023* Kaggle dataset which contains information about startups and the jobs they are offering. If we enter the prompt *Which startups are hiring engineer?* in Hal9, we will get an app that shows us a table with the required information.

<center><img src="Images/125.png" style="max-width: 70%"/></center>
<center><img src="Images/125.png" style="max-width: 70%"/></center>
<br>

You can check this example app [here](https://hal9.com/apps/startups-hiring-2023-example).


## Important concepts

- **Databases** are the systems used to store and manage digital information. These systems store data in an organized way and let users query it in order to extract important and relevant information. They are designed not only to store and manage data, but also to enable access and sharing of that information. They are used to store data for a variety of purposes, including recording transactions, managing inventory, supporting customer relationships, and making data-driven decisions.
Expand Down

0 comments on commit a5835ad

Please sign in to comment.