DEV Community

Emilio Ochieng
Emilio Ochieng

Posted on

Connecting Power BI to SQL Databases: From Local Servers to Cloud Platforms

Introduction

Connecting Power BI directly to a PostgreSQL database offers several advantages. It eliminates repetitive manual imports, improves data consistency, supports larger datasets, and allows reports to be refreshed whenever the underlying data changes.

This the process of connecting Power BI to both a local PostgreSQL database and a cloud-hosted PostgreSQL database on Aiven, including how to configure SSL for secure cloud connections.

Whats PostgreSQL?

PostgreSQL is one of the world's most popular open-source relational database management systems. It is trusted by startups, enterprises, and cloud providers because it is:

  • Open-source and free
  • Reliable and highly scalable
  • Secure
  • Excellent for analytics and reporting
  • Supported directly by Power BI

Requirements

Before starting, make sure you have:

  • PostgreSQL installed
  • DBeaver installed
  • Power BI Desktop
  • Aiven PostgreSQL account (for cloud connection)

Part 1: Connecting Power BI to a Local PostgreSQL Database

Step 1: Create Your PostgreSQL Database

Install PostgreSQL and create your database.

Open DBeaver and connect using:

  • Host: localhost
  • Port: 5432
  • Database: postgres
  • Username: postgres
  • Password: Your PostgreSQL password

Step 2: Import Your Dataset

Once connected:

  1. Expand Schemas.
  2. Open the public schema.
  3. Right-click and select Import Data.
  4. Choose your CSV or Excel dataset.
  5. Complete the import wizard.

Your tables should now appear inside the PostgreSQL database.

Step 3: Connect Power BI

Open Power BI Desktop.

Navigate to:

Home → Get Data → PostgreSQL Database

Enter:

Server

127.0.0.1:5432
Enter fullscreen mode Exit fullscreen mode

Database

postgres
Enter fullscreen mode Exit fullscreen mode

Since this database is running locally, leave Use Encrypted Connection unchecked.

Authenticate using your PostgreSQL credentials.

Power BI will display the available tables.

Select the tables you need and click Load.

Part 2: Connecting Power BI to a Cloud PostgreSQL Database (Aiven)

Cloud databases allow you to work from anywhere while providing security, scalability, backups, and high availability.

After creating a PostgreSQL service in Aiven, you'll receive:

  • Host
  • Port
  • Database
  • Username
  • Password
  • SSL Certificate

Step 1: Download the SSL Certificate

Cloud databases encrypt communication between your computer and the server.

Download the CA Certificate (ca.pem) from the Aiven dashboard.

Step 2: Import the Certificate into Windows

Search for:

Manage Computer Certificates

Navigate to:

Trusted Root Certification Authorities → Certificates

Right-click Certificates and select:

All Tasks → Import

Choose the downloaded ca.pem file and complete the Certificate Import Wizard.

Windows will confirm the import was successful.


Once selected, the following dialogue box will appear:

In this dialogue box, navigate to Trusted Root Certification Authorities and click on the drop-down arrow, then right click on Certificates, then go to All Tasks, then Import....

This will lead you to the following dialogue box:

Click Next, upload the certificate file which will have been downloaded as ca.pem from Aiven. You will be required to select the all files option when browsing your device for the certificate file. Continue until you get the confirmation that import is successful as shown below:

Step 3: Connect Power BI

Open Power BI Desktop.

Navigate to:

Home → Get Data → PostgreSQL Database

Enter:

Server

your-hostname:port
Enter fullscreen mode Exit fullscreen mode

Database

defaultdb
Enter fullscreen mode Exit fullscreen mode

check

Use Encrypted Connection

Authenticate using the username and password provided by Aiven.

Power BI will connect securely and display the available tables.

Select the required tables and click Load.

Local vs Cloud PostgreSQL

Local PostgreSQL Cloud PostgreSQL (Aiven)
Runs on your computer Hosted on cloud infrastructure
Uses localhost Uses a public hostname
SSL not required SSL certificate required
Ideal for development Ideal for production and collaboration
Limited remote access Accessible from anywhere

Common Connection Issues

If Power BI cannot connect to PostgreSQL, check the following:

  • Is PostgreSQL running?
  • Is the server name and port correct?
  • Are the username and password correct?
  • Has the SSL certificate been imported (for cloud databases)?
  • Is the PostgreSQL driver installed?
  • Is your firewall blocking the connection?

Most connection issues can be resolved by verifying these settings.

Why Connect Power BI Directly to PostgreSQL?

Connecting Power BI directly to PostgreSQL offers several benefits:

  • Faster reporting
  • Centralized data management
  • Improved security
  • Reduced manual work
  • Better scalability
  • Support for scheduled refreshes
  • Real-time insights when combined with DirectQuery

For organizations managing growing datasets, connecting Power BI directly to a database is a more efficient approach than repeatedly importing Excel files.

Final Thoughts

Learning how to connect Power BI to PostgreSQL is an important milestone for anyone pursuing a career in Data Analytics or Data Engineering.

Whether you're working with a local PostgreSQL server during development or a cloud-hosted PostgreSQL instance such as Aiven, the overall workflow remains the same: establish a connection, authenticate securely, load the required tables, and begin transforming raw data into actionable insights.

If you're learning Power BI, I encourage you to move beyond spreadsheets and start working directly with databases. It's a skill that mirrors real-world data environments and prepares you for more advanced analytics projects.

Thank you for reading! If you found this guide helpful, feel free to share your experience or ask questions in the comments.

Top comments (0)