BIPower BI Connectivity to PostgreSQL
Power BI Desktop Tool, PostgreSQL Database, pgAdmin III, Visual Studio 2008 or higher
Power BI supports connectivity to different databases such as SQL Server, MySQL, Oracle and many more (list of all supported databases given here ). By providing necessary details such as server name, database name, username & password, you can easily connect to database and start exploring data using different visualizations in the form of reports/dashboards.
This article will walk you through the necessary steps required to configure in your system before establishing connection of Power BI Desktop Tool to PostgreSQL Database.
After installation of PostgreSQL database in your machine, if you try connecting Power BI Desktop Tool to PostgreSQL Database, you will get following error as shown in the screenshot below:
Following are the steps required to connect Power BI Desktop Tool to PostgreSQL Database:
- Setup PostgreSQL Client
- Connect Power BI Desktop Tool to PostgreSQL
Steps to set up PostgreSQL Client:
Step 1: Download and unzip the Npgsql package from the link mentioned here
You will find two DLL files named as Npgsql.dll and Mono.Security.dll as shown in screen capture below:
Step 2: You need to have Visual Studio 2008 or later. Open visual studio command prompt using administrative rights as shown in the screen capture below:
Step 3: Locate and Open machine.config from the location given below:
.Net framework and Npgsql version might vary depending on the version of installation. Add the following below <DbProviderFactories> tag:
<add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Framework Data Provider for PostgreSQL Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=18.104.22.168, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7"/>
Find the screenshot given below for this step:
Step 4: Now in your visual studio command prompt, use the following command to successfully move DLL files to C:\windows\assembly
gacutil -I "C:\Users\ajagd_000\Downloads\Npgsql2.0.1-bin-ms.net3.5sp1\Npgsql2.0.1-bin-ms.net3.5sp1\bin\Npgsql.dll"
Where C:\Users\ajagd_000\Downloads is the file location for the Npgsql package downloaded.
Similar command you can run for Mono.Security.dll file
gacutil -I "C:\Users\ajagd_000\Downloads\Npgsql2.0.1-bin-ms.net3.5sp1\Npgsql2.0.1-bin-ms.net3.5sp1\bin\Mono.Security.dll"
Step 5: Once this is done, you can now try connecting Power BI to PostgreSQL. However you will notice below error
Once you restart your machine, you can now connect to PostgreSQL and start playing with your data.
Steps for connecting Power BI Desktop Tool to PostgreSQL:
Step 1: Open pgAdmin III interface to create database, table and few records to display in your report as shown in screen capture below
Step 2: Open Power BI Desktop Tool and click ‘Get Data’ and select PostgreSQL Database as shown below
Step 3: Enter server name (in our case it is localhost), database name, username and password as shown in below screen capture
Step 4: Select required table from database and click load as shown in screen capture below
Step 5: Once data is loaded in model, you can start playing around with the data and create beautiful visualizations/reports as shown in image below and later publish it to Power BI Online Service.