How to connect Power BI to PostgreSQL

Viewed 18951

I want get data into Power BI desktop from PostgreSQL (on my local machine). I tried the solution given here (Installing ngpsql to use PostgreSQL in PowerBI), but it did not work.

Basically, I installed the latest version of ngpsql(3.2.4) with the option to install to GAC. However, I'm getting the same error in Power BI saying that the connector requires one or more additional components.

Am I missing any steps? I looked online but did not find any recent documentation on this.

Any help is very much appreciated.

Thanks

2 Answers

Three ways :

1 - The ngpsql way does work if your follow the comment of Lavande:

  1. Install npgsql as Administrator (since the DLL would be pushed to GAC);
  2. During the installation stage, enabled "Npgsql GAC Installation";
  3. Restart the PC

2 - With ODBC, i used this walk-through

  • install ODBC connector here
  • start it and create a new connection (DSN)
  • in Power BI, get data, ODBC,PostGreSQL, no options
  • enter the credentials.
  • select the table(s) of interest.

3 - With the M query language.

Nota : the Power BI community posts ? well, ...

Another option to solve this problem is to create a Python script to connect to Postgresql.

Using a script like this:

import psycopg2
import pandas as pd

con = psycopg2.connect(host='localhost', database='Your DataBase',
user='user', password='password')
cur = con.cursor()


cur.execute('Your Query')
data = cur.fetchall()

df = pd.DataFrame(data, columns=['Your Columns'])
Related