π 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.
2. Gather Local Connection Details
Make sure you have:
Host: localhost
Port: 5432
Database: your_database_name
Username: your_username
Password: your_password
3. Connect Power BI to Local PostgreSQL
- Open Power BI Desktop
- Click Get Data β More...
- Select PostgreSQL database
- Enter your connection details:
Server: localhost
Database: your_database_name
- 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)
2. Connect Power BI to Aiven with SSL Enabled
- Open Get Data β PostgreSQL database
- Enter:
Server: your-service-name.aivencloud.com
Database: defaultdb
Port: your_port
- Open Advanced options and add:
SSL Mode=Require
- 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)