Connect to a PostgreSQL database

Before you can connect to a PostgreSQL database, you need the Npgsql - .Net Data Provider for Postgresql 2.0.12 on your computer. To install the Npgsql - .Net Data Provider for Postgresql 2.0.12, go to http://go.microsoft.com/fwlink/?LinkID=282716. The driver bit-ness needs to match the Microsoft Power Query for Excel add-in installation (32-bit or 64-bit).

Connect to a PostgreSQL database   

 Note    Before you connect to a PostgreSQL database, the PostgreSQL .Net Data Provider needs to be installed. To install the PostgreSQL .Net Data Provider, see Install the PostgreSQL .Net Data Provider.

  1. In the POWER QUERY ribbon tab, click From Database > From PostgreSQL Database.
  2. In the PostgreSQL Database dialog box, in Server Name specify the PostgreSQL Database Server to connect to.
  3. If you want to import data using native database query, specify your query in the SQL Statement box. For more information, see Import Data from Database using Native Database Query.
  4. Click OK.
  5. If the PostgreSQL server requires database user credentials:
  1. In the Access a Database dialog box, enter your username and password.
  2. Click Save.

Top of Page Top of Page

Install the PostgreSQL .Net Data Provider

  1. Download and unzip the “NPQSql 2.0.12 driver for MS.Net 2.0”.
  2. Use GACUtil.exe to add Npgsql.dll and Mono.Security.dll to the global cache.

Syntax

"{GACUtil Path}\GACUtil" /i "{Provider DLL Path}\Npgsql.dll"
"{GACUtil Path}\GACUtil" /i "{Provider DLL Path}\Mono.Security.dll"


Where
GACUtil Path

  • For x86
    • C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\
  • For x64
    • C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64

Provider DLL Path

  • Path to Npgsql.dll and Mono.Security.dll
  1. Add a new entry to the machine.config file:
  1. Navigate to “C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG” (or “C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG” if running 64 bit).
  2. Open the “machine.config” file with admin privileges.
  3. Look for a node called "DbProviderFactories".
  4. Add a new entry:

<add description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.0.12.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" name="Npgsql Data Provider" invariant="Npgsql" support="FF"/>

  1. Save machine.config.

Top of Page Top of Page

Related Topics

Import data from external data sources

 
 
Applies to:
Excel 2013, Excel 2010