How to get a free PostgreSQL database in the Cloud
Hi and welcome to my blog.
Today I want to show you a website that allows you to get your own PostreSQL database accessible from the Internet.
You might be wondering why you might need to use such a service when you can simply install PostgreSQL on your PC and use it.
Well, this would be a valid option if what you need is local access to the database from within your local network. But when you need to access those databases from the public Internet (from a SaaS tool for example) then things get a little complicated for using your local database server.
One could provision a PostgreSQL database on one of the three major cloud providers (Amazon Web Services, Microsoft Azure or Google Cloud Platform) but those providers will bill you by the hour and this would be a really expensive option for many of us who just want a Postgres database to play with.
This is where the service I will demonstrate to you today really shines and comes in very handy when you need a free database.
I’m convinced, show me the service
The service I will be talking about today are is called “ElephantSQL”
Why did I choose to show you this service ? Simply because they truely offer access to free PostgreSQL databases hosted and managed by their teams. These databases never expire and are never decomissioned (at least at the time of writing this article).
ElephantSQL (www.elephantsql.com) describe themselves as a “PostgreSQL as a Service” provider. As their tagline suggests they only provide PostgreSQL databases.
Before being able to request a PostreSQL database you will need to register on their website by following this link: https://customer.elephantsql.com/signup.
Once you provide a valid email address and verify it, you are ready to go.
ElephantSQL offer many PostgreSQL hosting plans, all of them are paid options except one called “TinyTurtle”.
This micro database offering comes with some limitations as can be seen in the below screenshot.
But this offering is most of the time enough for our testing purposes (at least for my use cases it is completely acceptable).
Now, let’s see how we can provision a “TinyTurtle” instance.
Simply click on “Create New Instance” and follow the steps of the instance provisioning wizard.
You will need to provide a name for your database and select an Amazon Web Services region where it will be hosted.
Once you click on “Create Instance” your database is provisioned and ready to use.
Connecting to your newly created database
You can connect to your ElephantSQL database from any tool or piece of code you might be writing.
For the purpose of illustrating this here in this blog, I will use the free pgAdmin tool that I have already installed on my PC.
If you don’t have pgAdmin you can get an installation package for your operating system from the following link www.pgadmin.org
In pgAdmin you will need to add a connection to a new server and use the connection settings that ElephantSQL provided you.
Once connected to the PostgreSQL server you might need to scroll in the “Databases” tree hierarchy on the left and select the name of the database assigned to you by ElephantSQL (your database is hosted on a shared PostgreSQL server for obvious cost optimization reasons).
Once you have selected your database, you can right-click on it and select the “Query Tool”.
All you have to do now is enjoy typing SQL statements and see them get executed against your database.
Here are my example statements to confirm my database is working well:
CREATE TABLE CUSTOMER(Id int, Name varchar(50))
INSERT INTO CUSTOMER VALUES (1, 'ACME Corp')
INSERT INTO CUSTOMER VALUES (2, 'NorthStar Corp')
SELECT * FROM CUSTOMER
If all went well you should see an output like below.
In Conclusion
In this article I have showed you how you can get a free Internet accessible PostgreSQL database. Enjoy using your new database and practicing your SQL skills.