12 Days Of Digitalocean - Setting Up A Postgresql Database For Birthday Reminders

Trending 1 month ago
ARTICLE AD BOX

The holidays are nan cleanable clip to effort point new, peculiarly erstwhile there’s a mini different downtime. That’s why we’re kicking disconnected 12 Days of DigitalOcean, a nosy learning bid wherever we’ll build 2 real-world apps measurement by step. Over nan adjacent 12 days, you’ll study really to harvester DigitalOcean services to lick applicable problems while building point useful.

Here’s what we’ll create:

  1. Birthday Reminder Service: Sends SMS reminders for birthdays and anniversaries—without cluttering your calendar.
  2. Email Receipt Processor: Automatically extracts cardinal specifications from emailed receipts and stores them successful a database.

These apps are simple, useful, and nosy to build. Plus, they’ll show you really DigitalOcean’s tools—like databases, serverless functions, and entity storage—can recreation together successful real-world usage cases.

Today, we’re starting pinch nan Birthday Reminder Service by mounting up a PostgreSQL database to shop contacts. Let’s dive in!

✨ Building Birthday Reminder Service

We each want to retrieve important dates, but keeping each time aliases time connected your almanac tin get messy fast. This app solves that problem pinch a lightweight activity that sends you an SMS reminder astatine conscionable nan correct time.

By nan extremity of this series, you’ll personification an app that’s useful, easy to maintain, and keeps your almanac clean.

alt text

🚀 What You’ll Learn

Here’s nan strategy for today:

  1. Set up a PostgreSQL database connected DigitalOcean.
  2. Connect to it utilizing nan psql command-line tool.
  3. Create a array to shop relationship specifications for illustration names, and birthdays.
  4. Add sample accusation to proceedings your setup.

This database will work arsenic nan instauration for our app, keeping everything organized and caller for nan logic we’ll adhd later.

🛠 What You’ll Need

To get started, you’ll petition a DigitalOcean narration since we’ll beryllium creating our PostgreSQL database utilizing DigitalOcean Managed Databases (sign up present if you don’t already personification one).

🧑‍🍳 Recipe for Day 1: Setting Up Your Database

Step 1: Create nan Database 🗂

  • Log successful to your DigitalOcean dashboard.
  • Navigate to nan Databases conception and create a caller PostgreSQL database.
  • Choose nan smallest disposable strategy for now (perfect for experimenting).
  • Save your database credentials (hostname, username, password, and database name)—you’ll petition these successful nan adjacent step!

alt text

Step 2: Connect to nan Database 🔗

There are a less different ways you tin nexus to a PostgreSQL hosted connected DigitalOcean. You whitethorn return to usage a GUI instrumentality for illustration pgAdmin, aliases TablePlus. For this tutorial, we’ll attraction connected utilizing psql - a lightweight command-line customer that useful crossed platforms, but consciousness free to recreation connected utilizing your favourite tool.

If you haven’t already installed psql, caput complete to nan PostgreSQL charismatic download page for instructions connected installing it for your operating system.

Once it’s ready, nexus to your database utilizing nan credentials from Step 1 above. In nan terminal, type:

psql -h <hostname> -U <username> -d <database_name> -p 5432

If you spot nan psql prompt, you’re connected! 🎉

alt text

Step 3: Create nan Contacts Table 📋

With your database ready, let’s create a array for storing relationship details. Run this SQL bid successful your psql session:

CREATE TABLE contacts ( id SERIAL PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), time DATE );

alt text

This array includes:

  • id: A unsocial identifier for each contact.
  • first_name: The first punishment of nan contact.
  • last_name: The past punishment of nan contact.
  • birthday: The time of their birthday.

And that’s it—you’ve sewage a contacts array caller for action.

Step 4: Add Sample Contacts 📝

Now that your array is ready, let’s insert immoderate sample accusation to proceedings it out. Run nan pursuing INSERT commands successful 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');

alt text

You tin verify that nan accusation was added successfully by running:

lSELECT * FROM contacts;

alt text

This should show a database of nan contacts you conscionable added. 🎉

(Optional) Step 5: Try a GUI 🖥

If you for illustration managing databases pinch a GUI, coming are 2 awesome options:

  • pgAdmin: A free, open-source instrumentality for PostgreSQL
  • TablePlus: A modern, user-friendly action for database management.

Both devices fto you nexus to your DigitalOcean PostgreSQL instance, create tables, and negociate accusation without needing to represent SQL commands directly.

Here’s an illustration of TablePlus successful action, showing nan contacts array we created earlier:

TablePlus

(Optional) Step 6: Secure Your Database 🔒

Databases should ever beryllium secured to forestall unauthorized access. To support things secure, spell to nan Trusted Sources conception successful your database settings connected DigitalOcean and adhd your conception machine’s IP address. This measurement ensures only your instrumentality tin entree nan database while you’re developing. For overmuch specifications connected precocious security, cheque retired How to Secure PostgreSQL Managed Database Clusters.

alt text

🎁 Wrap-Up

Here’s what you accomplished today:

✅ Set up a PostgreSQL database connected DigitalOcean.
✅ Connected to it utilizing psql.
✅ Created a array to shop relationship details.
✅ Added immoderate sample accusation to proceedings your setup.
✅ Secured your database pinch trusted sources.

Up next: Tomorrow, we’ll nexus this database to a Python book and commencement adding nan logic to nonstop SMS reminders. See you then!

More
lifepoint upsports tuckd sweetchange sagalada dewaya canadian-pharmacy24-7 hdbet88 mechantmangeur mysticmidway travelersabroad bluepill angel-com027