DEV Community

teresa kungu
teresa kungu

Posted on

##How to Connect Power BI to Aiven PostgreSQL

πŸ“Œ Prerequisites

  • Power BI Desktop installed
  • PostgreSQL (local or Aiven)
  • Basic understanding of database credentials (host, username, password)

🟦 1. Connect Power BI to Local PostgreSQL

1. Install PostgreSQL ODBC Driver

Download and install the PostgreSQL ODBC driver (psqlODBC) from the official PostgreSQL website.

image


2. Gather Local Connection Details

Make sure you have:

Host: localhost
Port: 5432
Database: your_database_name
Username: your_username
Password: your_password
Enter fullscreen mode Exit fullscreen mode

3. Connect Power BI to Local PostgreSQL

  1. Open Power BI Desktop
  2. Click Get Data β†’ More...
  3. Select PostgreSQL database

image

  1. Enter your connection details:
Server: localhost
Database: your_database_name
Enter fullscreen mode Exit fullscreen mode
  1. Click OK and enter your username & password.

4. Load Tables

Power BI will display all tables in your PostgreSQL database.

Select the tables you want β†’ click Load.

`


🟦 2. Connect Power BI to Aiven PostgreSQL (Cloud)

Aiven requires SSL, but the setup is straightforward.


1. Get Aiven PostgreSQL Credentials

From your Aiven dashboard:

  • Open your PostgreSQL service
  • Go to Overview
  • Copy your connection details:

    • Host
    • Port
    • Database
    • Username
    • Password
    • SSL mode (Required)

image


2. Connect Power BI to Aiven with SSL Enabled

  1. Open Get Data β†’ PostgreSQL database
  2. Enter:


Server: your-service-name.aivencloud.com
Database: defaultdb
Port: your_port

  1. Open Advanced options and add:


SSL Mode=Require

  1. Click OK β†’ Enter your password.

3. SSL Troubleshooting

If you get certificate errors, try:


SSL Mode=Verify-Full

or download the Aiven CA certificate and configure it.


🟦 Optional: Use Connection Strings

Local PostgreSQL:


Server=localhost;Port=5432;Database=myDB;UID=myUser;PWD=myPassword;

Aiven PostgreSQL:


Server=your-host.aivencloud.com;Port=12345;Database=defaultdb;UID=avnadmin;PWD=yourPassword;SSL Mode=Require;


🟦 Power Query (M Code) Example

m
let
Source = Postgres.Database(
"your-host.aivencloud.com",
"defaultdb",
[
Port=12345,
SSLMode=1,
User="avnadmin"
]
)
in
Source


🟦 Best Practices

πŸ” Security

  • Never publish passwords in articles or dashboards
  • Use Power BI Gateway for scheduled refresh

⚑ Performance

  • Use DirectQuery for real-time dashboards
  • Use Import mode for better performance on large mode

🟦 Conclusion

You now know how to connect Power BI to:

  • Local PostgreSQL
  • Aiven PostgreSQL (with SSL)

This simple setup allows you to start building powerful dashboards quickly.

Top comments (0)