Table of Contents
URL: https://www.progressiverobot.com/setting-up-postgresql-database-for-birthday-reminders/
The holidays are the perfect time to try something new, especially when there’s a little extra downtime. That’s why we’re kicking off 12 Days of the cloud provider, a fun learning series where we’ll build two real-world apps step by step. Over the next 12 days, you’ll learn how to combine the cloud provider services to solve practical problems while building something useful.
Here’s what we’ll create:
- Birthday Reminder Service: Sends SMS reminders for birthdays and anniversaries—without cluttering your calendar.
- Email Receipt Processor: Automatically extracts key details from emailed receipts and stores them in a database.
These apps are simple, useful, and fun to build. Plus, they’ll show you how the cloud provider’s tools—like databases, serverless functions, and object storage—can come together in real-world use cases.
Today, we’re starting with the Birthday Reminder Service by setting up a PostgreSQL database to store contacts. Let’s dive in!
✨ Building Birthday Reminder Service
We all want to remember important dates, but keeping every birthday or anniversary on your calendar can get messy fast. This app solves that problem with a lightweight service that sends you an SMS reminder at just the right time.
By the end of this series, you’ll have an app that’s useful, easy to maintain, and keeps your calendar clean.
🚀 What You’ll Learn
Here’s the plan for today:
- Set up a PostgreSQL database on the cloud provider.
- Connect to it using the
psqlcommand-line tool. - Create a table to store contact details like names, and birthdays.
- Add sample data to test your setup.
This database will serve as the foundation for our app, keeping everything organized and ready for the logic we’ll add later.
🛠 What You’ll Need
To get started, you’ll need a cloud account since we’ll be creating our PostgreSQL database using managed databases (sign up here if you don’t already have one).
🧑🍳 Recipe for Day 1: Setting Up Your Database
Step 1: Create the Database 🗂
- Log in to your the cloud provider dashboard.
- Navigate to the Databases section and create a new PostgreSQL database.
- Choose the smallest available plan for now (perfect for experimenting).
- Save your database credentials (hostname, username, password, and database name)—you’ll need these in the next step!
Step 2: Connect to the Database 🔗
There are a few different ways you can connect to a PostgreSQL hosted on the cloud provider. You may choose to use a GUI tool like pgAdmin, or TablePlus. For this tutorial, we’ll focus on using psql – a lightweight command-line client that works across platforms, but feel free to follow along using your favorite tool.
If you haven’t already installed psql, head over to the PostgreSQL official download page for instructions on installing it for your operating system.
Once it’s ready, connect to your database using the credentials from Step 1 above. In the terminal, type:
psql -h <hostname> -U <username> -d <database_name> -p 5432
If you see the psql prompt, you’re connected! 🎉
Step 3: Create the Contacts Table 📋
With your database ready, let’s create a table for storing contact details. Run this SQL command in your psql session:
CREATE TABLE contacts (
id SERIAL PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
birthday DATE
);
This table includes:
id: A unique identifier for each contact.first_name: The first name of the contact.last_name: The last name of the contact.birthday: The date of their birthday.
And that’s it—you’ve got a contacts table ready for action.
Step 4: Add Sample Contacts 📝
Now that your table is ready, let’s insert some sample data to test it out. Run the following INSERT commands in your psql session:
INSERT INTO contacts (first_name, last_name, birthday)
VALUES ('Alice', 'Smith', '1990-05-15');
INSERT INTO contacts (first_name, last_name, birthday)
VALUES ('Bob', 'Johnson', '1985-11-23');
INSERT INTO contacts (first_name, last_name, birthday)
VALUES ('Charlie', 'Brown', '2000-01-10');
You can verify that the data was added successfully by running:
lSELECT * FROM contacts;
This should display a list of the contacts you just added. 🎉
(Optional) Step 5: Try a GUI 🖥
If you prefer managing databases with a GUI, here are two great options:
Both tools let you connect to your the cloud provider PostgreSQL instance, create tables, and manage data without needing to write SQL commands directly.
Here’s an example of TablePlus in action, showing the contacts table we created earlier:
(Optional) Step 6: Secure Your Database 🔒
Databases should always be secured to prevent unauthorized access. To keep things secure, go to the Trusted Sources section in your database settings on the cloud provider and add your local machine’s IP address. This step ensures only your computer can access the database while you’re developing. For more details on advanced security, check out How to Secure PostgreSQL Managed Database Clusters.
🎁 Wrap-Up
Here’s what you accomplished today:
- Set up a PostgreSQL database on the cloud provider.
- Connected to it using
psql. - Created a table to store contact details.
- Added some sample data to test your setup.
- Secured your database with trusted sources.
Up next: Tomorrow, you’ll connect this database to a Python script and add the logic to send SMS reminders. Here is the next tutorial on Day 2: Connecting to Your PostgreSQL Database with Python.
Here are the other tutorials from this series:
First Project - Birthday Reminder Service
Sends SMS reminders for birthdays and anniversaries—without cluttering your calendar.
- Day 1: Set up a PostgreSQL database to store contacts
- Day 2: Built a Python script to connect to the database and fetch birthdays
- Day 3: Added functionality to send SMS reminders using Twilio
- Day 4: Deployed the app to the cloud provider Functions to make it serverless and scalable
- Day 5: Automated reminders to run on a schedule
- Day 6: Set up logging to capture and save logs using services like PaperTrail
Second Project - Email Receipt Processor
Automatically extracts key details from emailed receipts and stores them in a database.