There are a variety of methods to import Excel to PostgreSQL; some are simple, while others are more complicated, depending on the sort of data you receive and the format it is in.

In this article, you will discover four effective approaches for establishing a connection and seamlessly migrating your data from Excel to PostgreSQL. We’ll look at using ODBC drivers, integrating Excel and PostgreSQL via CSV files, and using a powerful tool like pgAdmin and using Microsoft Query to move data from Excel to PostgreSQL easily.

Methods to Connect & Import Excel to PostgreSQL

There are many methods to import data from Excel to PostgreSQL. You will gain an understanding of four of them.

Simplify PostgreSQL ETL & Analysis with Hevo’s No-code Data Pipeline

Hevo Data, a No-code Data Pipeline helps to load data from any data source such as Google Sheets, FTP, Google Search Console, SaaS applications, Cloud Storage, SDKs, and Streaming Services to a destination of your choice like PostgreSQL and simplifies the ETL process like Excel to PostgreSQL. It supports 150+ data sources (including 40+ free data sources) and is a 3-step process by just selecting the data source, providing valid credentials, and choosing the destination. Hevo not only loads the data onto the desired Data Warehouse/destination but also enriches the data and transforms it into an analysis-ready form without having to write a single line of code.

Get started with hevo for free

Method 1: Integrating Excel to PostgreSQL using ODBC Drivers 

Get & Transform (Power Query) can be used to setup an Excel PostgreSQL connection using ODBC. This approach presupposes you’ve installed a PostgreSQL ODBC Driver.

Step 1: Install ODBC Drivers for PostgreSQL

The first step in Excel to PostgreSQL data transfer is to install ODBC Driver. The PostgreSQL ODBC 64-bit driver is available for download. On the machine where the Secure Agent is installed, install the PostgreSQL ODBC driver.

Step 2: Configure Postgres ODBC Driver in Excel

Expand the Get Data drop-down box after clicking Data in Excel. Select From Other Sources > From ODBC from the drop-down menu.

Excel to PostgreSQL: Configuring ODBC driver in excel
Configuring ODBC driver in excel

Step 3: Authorize Connection with PostgreSQL

Choose your data source name in the From ODBC dialogue (DSN). You can expand the Advanced Options dialogue box and input the connection string for your Data Source if you haven’t yet established your ODBC Driver (without credentials, which are defined in the credentials dialogue box in the next step). You can also enter a SQL query that will be performed immediately after connecting to the data source. Click the OK button.

Excel to PostgreSQL: Setting up the ODBC connection
Setting up the ODBC connection

Select Database and input your credentials in the dialog box, then click Connect if you’re using a database Username or Password. Select Default or Custom and press Connect if your database is not password-protected or if you’ve previously entered your credentials in the ODBC Data Source settings.

Excel to PostgreSQL: Connecting to Database
Connecting to Database

Step 4: Load Data in Microsoft Excel

Select the table from which you wish to retrieve data in the pop-up box and click on Load.

Excel to POstgreSQL: Select the Required Table
Select the Required Table

The table’s data will be displayed in an Excel spreadsheet, where you can interact with it further.

Excel to PostgreSQL: Table Data Loaded in Excel sheet
Table Data Loaded in Excel sheet

You have successfully completed Excel to PostgreSQL data transfer via ODBC Driver.

Learn more about – How to import excel into MySQL and import excel into Bigquery.

Method 2: Integrating Excel to PostgreSQL via CSV Files 

Step 1: Excel File Conversion

The first step in the CSV method in Excel to PostgreSQL data transfer is to use Excel File Conversion. Open your file in Microsoft Excel if the file extension is xls or xlsx. This will need to be converted to a CSV file, which is a simple process. Simply Save As and modify the “Save as type:” to “CSV (*.csv)” before clicking Save. There is no need to change the file name to .csv because it will change automatically.

Step 2: CSV File Connection

Click Create and then Connection after right-clicking your Database Connection (or anyplace if your connections are empty). On the left, make sure the All tab is chosen, then scroll down to CSV. Now click Next.

Excel to PostgreSQL: Select Your Database
Select Your Database

Select the folder where you saved your CSV file from Microsoft Excel by clicking Browse. You’re choosing a folder rather than a file. All CSV files in that folder will be loaded by the connection. Finish by clicking the Finish button.

You should now notice a new connection, which is configured similarly to a standard connection. Each of the CSV files in your folder will be organized into a table with columns.

Step 3: Data Import

Data Import is the last step in the process of Excel to PostgreSQL data transfer. After you’ve established the Excel connect to PostgreSQL, you may query the data using SQL syntax, just like any other table. This data can now be imported into your PostgreSQL Table. Select Export Data from the context menu of the table you want to import into PostgreSQL.

Excel to PostgreSQL: Export Data
Export Data

Click Next after selecting Database. Change the target container to the schema in PostgreSQL where your table resides. Click on the OK button.

Excel to PostgreSQL: Change the Target Container
Excel to PostgreSQL: Change the Target Container

Choose the target (table) for the data to be imported. Set the target column for each data column by clicking Columns. This will map automatically if you have headers in your data that match the table columns. Click the OK button. Now, Next should be selected.

Excel to PostgreSQL: Choose the Target Table
Choose the Target Table

Set the connection and Data Load options. Remove the option for truncating the target table if you only want to add data to the table rather than rewriting it. Now, Next should be selected.

After you’ve double-checked that the source and target are correct, click Start to begin the PostgreSQL Excel import.

The data from your PostgreSQL table is now available for selection.

Excel to PostgreSQL: Data has been exported to PostgreSQL
Data has been exported to PostgreSQL

You have completed Excel to PostgreSQL data transfer via CSV files.

Method 3: Transfer data from Excel to a PostgreSQL Database using pgAdmin

  • Convert your Excel spreadsheet into a CSV file. To do this, click on file, then save as. In the drop-down bar that appears, pick CSV (Comma delimited), and then hit save.
Excel to PostgreSQL: Select the CSV file format after clicking on Save As
Select the CSV file format after clicking on Save As
  • Create an empty table in PostgreSQL with the identical column names, data types, and column constraints as your Excel sheet’s columns.
Excel to PostgreSQL: Create a blank table in postgresql with the same schema as the source table
Create a blank table in postgresql with the same schema as the source table
  • In PostgreSQL, right-click on the newly formed table; a selection of choices will display; select the ‘import/export’ option.
Excel to PostgreSQL: Select import/export option
Select import/export option
  • At this stage, a dropdown menu displays. Here’s how to use the dropdown box:
    • Choose the import option.
    • On the file name tab, pick your excel sheet from your PC by clicking the select file (…) button.
    • Choose ‘yes’ for the header choice.
    • Choose the comma (,) delimiter as the delimiter choice.
    • Click ‘OK’.
Excel to PostgreSQL: Enter the filename of the csv file to be imported
Enter the filename of the csv file to be imported
  • If all rules are followed correctly, an import task is produced. A process observer appears to assist you in keeping track of what’s going on.
Excel to PostgreSQL: Process to import the data from CSV file
Process to import the data from CSV file
  • You’ve successfully loaded the table into your relational database management system.
Successfully imported the data from the CSV file
Excel to PostgreSQL: Successfully imported the data from the CSV file

Method 4 : Move Data from PostgreSQL Database to Excel using Microsoft Query

Here’s a detailed guide on how to establish a connection between Microsoft Excel and a PostgreSQL database using Microsoft Query:

Step 1: Begin by opening the Excel sheet where you intend to import data from PostgreSQL. To do this, go to the “Data” tab, then select “Get Data,” followed by “From Other Sources,” and finally choose “From Microsoft Query.”

Excel to PostgreSQL: Select the From Microsoft Query option
Select the From Microsoft Query option

Step 2: In the next window, select the desired data source and make sure to enable the option that says, “Use the Query Wizard to create/edit queries.” Confirm your selection by clicking the “OK” button.

Step 3: Now, you’ll need to specify the database connection details. This includes providing the database name, username, and password. Once entered, click the “OK” button to proceed.

Step 4: In this step, you can select the specific tables you want to import into Excel. Additionally, you have the option to apply filters or sort data in rows and columns as needed. To add the selected tables, click the “Add” button.

With these steps completed, you will see that your PostgreSQL data has been successfully loaded into an Excel sheet.

Furthermore, you have the option to utilize other features in the “Get Data” tab, such as the Data Connection Wizard, Power Pivot, and Query Wizard, to export query results from your PostgreSQL database to Excel.

  • Power Pivot: This Excel add-in empowers you to import data from external sources, including PostgreSQL databases. While importing, you can apply data filters or rename columns. After the import, Power Pivot efficiently organizes the tables on separate sheets in Excel. Moreover, you can utilize the Data Analysis Expression language within Power Pivot to create advanced formulas, allowing you to craft custom data models.
  • Query Wizard: The Query Wizard serves as a valuable tool to create and modify queries for accessing your database’s stored data.

Conclusion

This article teaches you about Excel to PostgreSQL. It provides in-depth knowledge about the concepts behind every step to help you understand and implement them efficiently. If you want to transfer data into your desired Database/destination, then Hevo Data is the right choice! 

You can also check out our guide to Import Excel into MySQL Database.

Visit our Website to Explore Hevo

Want to take Hevo for a spin? Sign Up for a 14-day free trial and experience the feature-rich Hevo suite firsthand. You can also have a look at our unbeatable Hevo Pricing that will help you choose the right plan for your business needs!

Share your experience of learning about Excel to PostgreSQL! Let us know in the comments section below!

Frequently Asked Questions

Q. How do I send data from Excel to PostgreSQL?

You can transfer Excel data to PostgreSQL in two ways:

  1. Export as CSV & Import with COPY: Save as CSV, then use PostgreSQL’s COPY command.
  2. ODBC Driver: Install a driver to connect Excel directly to PostgreSQL.

Q. Can Postgres read an Excel file?

PostgreSQL cannot directly read Excel files. You typically need to export the data from Excel to a compatible format like CSV and then import it into PostgreSQL.

Q. Can you connect Postgres to Excel?

Yes, you can connect Postgres to Excel, but Excel itself can’t handle databases directly. There are two main approaches:

  1. ODBC Drivers: Install a third-party ODBC driver for PostgreSQL. This lets Excel connect and import/export data from your Postgres database.
  2. Export & Import:
    • Export your Excel data to a format like CSV.
    • Use tools or commands within PostgreSQL to import the CSV file.
mm
Former Research Analyst, Hevo Data

Harsh comes with experience in performing research analysis who has a passion for data, software architecture, and writing technical content. He has written more than 100 articles on data integration and infrastructure.

No-code Data Pipeline for PostgreSQL