DEV Community

Cover image for How to Import/Export CSV file in pgAdmin
Syeda Maham Fahim
Syeda Maham Fahim

Posted on

1

How to Import/Export CSV file in pgAdmin

Working with databases often involves handling large amounts of data. One of the most common ways to import or export data is through CSV files.

This article covers simple steps for importing and exporting CSV files using pgAdmin.

Let’s get started!

Importing CSV into pgAdmin

  1. Right-click on the table where you want to import the CSV file.

    • A popup will appear. Table Right Click
  2. Click on the folder icon (highlighted in the green square).

    • A new popup will open. popup
  3. Click on the three horizontal dots on the right side of the popup.

    • A dropdown menu will appear with the “Upload” option. Upload option
  4. Upload the file.

    • After selecting the "Upload" option, a new popup will appear where you can choose your file. upload popup
    • Note: The maximum file size is 50MB, so make sure your file doesn't exceed this limit.
  5. Close the popup by clicking on the first 'X' button. Don’t click the second one as it will remove the file from the list.
    close button

  6. Select the file you just uploaded.
    selection

  7. Ensure the CSV Columns Match the Database.

    • Make sure the columns in your CSV match those in your database table.
    • In the screenshot below, the database columns are id, published_date, city, etc. database columns
  8. CSV Columns.

    • Similarly, ensure that your CSV file has the same columns in the same positions as the database. csv
    • Note: The id column is not included in the CSV because PostgreSQL will generate this automatically.

Excluding Unwanted Columns

  1. Exclude unwanted columns.

    • In the "Columns" tab, remove the columns that you don’t want to import (e.g., id, created_at, updated_at). exclude_columns
  2. Click OK to complete the import process. Your CSV file will be successfully imported into pgAdmin.


Exporting CSV from pgAdmin

  1. Go to the Export tab and click the folder icon to choose the file location where you want to export your data.

  2. Click the 'Export' button to start the process. Once completed, a success message will appear
    success message

Accessing the Exported CSV

  1. Where to find your exported CSV file?

    • Don’t worry! You can easily find your exported file by clicking on the Tools option in the header, followed by Storage Manager. Storage Manager
  2. A new popup will show all your stored files.
    all_files

  3. Select the file and click on the download button to get your exported CSV file.


Conclusion

And there you have it!

You've learned how to import and export CSV files in pgAdmin easily.

This process is quite simple once you get the hang of it, and it's a great way to manage your data.

Stay Connected - @syedamahamfahim 🐬

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more