Skip to main content

Introduction

This tutorial takes you from zero to a live, connected database in a few minutes: create the instance from the dashboard, grab its connection string, and connect to it from your own code.

Prerequisites

  • Square Cloud Account: Create your account through the signup page.
  • Active Standard plan or higher: Managed databases require an active Standard plan or higher. Check the available plans and choose the one that fits your workload.

Step 1: Choose an engine

Square Cloud offers four managed database engines, already configured to connect and start using: This tutorial uses PostgreSQL, but the same dashboard flow applies to every engine above.

Step 2: Create the database

1

Create a new database instance

Go to the Databases page and click on the “Create Database” button.
2

Setting up your database instance

Select PostgreSQL (or the engine you chose in Step 1) and fill in the required information, such as the database name and RAM.
3

Finish your instance creation

Click on the “Create” button and wait for the database to be created.

Step 3: Get the connection string

Once your database is ready, open it from the Databases page. The connection details — host, port, username, password and connection URL — are shown in the database dashboard, alongside the TLS certificate you’ll need to connect.
Square Cloud databases only accept SSL/TLS connections. See how do I connect to my database for how the certificate is used by different clients.

Step 4: Connect from your code

With the connection string in hand, connect using your language’s PostgreSQL client.
Install the pg package:
Connect and verify with a simple query:
index.js
If the query returns a result instead of raising a connection error, your application is talking to the database successfully.
Never hardcode the connection string in your source code. Set it as an environment variable (DATABASE_URL) through your configuration file or the dashboard, so credentials never end up in your repository.

Your database is live

You now have a managed database running and reachable from your code. From here:

Deploy an app to use it

Host the application that connects to this database on Square Cloud.

Snapshots

Create and restore database snapshots from the CLI.

Contact us

If you continue facing technical difficulties, our specialized support team is available to assist you. Contact us and we’ll be happy to help you resolve any issue — support quality is a big part of why developers rate Square Cloud 4.9/5 across 402 reviews on Google and Trustpilot.