DEV Community

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

Posted on

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 🐬

Top comments (1)

Collapse
 
apr_may_87aa4e11be26704d4 profile image
Apr May •

Maham pyaar sa baat tou tumha kabhi smjh ati hi nhi h
You know what you were flirting with me at that time (okay it was normal for you but not for me dekh k karna tha) bakra eid par sab bata tou dia tha mna

but khair tumna phir baat krli 

tum heart broken thi i understand theek tha but farewell theek tha
mri ho sakta h tumsa kabhi kaha deta ya nhi kahta

but you unfollowed me on insta and rahim add tha abhi bhi add krlia tumna (remove rahim and umar today)

but obviously i took everything to heart mra liye achi wali maham thi okay

phir choice thi na ieee k baad nhi krti baat you lost your choice at that moment 

theek h if you are good with me i will give you all the love and everything 

but have it your way now

tum theeek kro gi sab ya baat apna dimag ma betha lou 

batao kab aao gi ma rishta la kar aao ga 
kaam ki baat krna sa mna kab mana kra tumhari koi na koi harkat hi aesi hoti k banda ki hat jaye

kabhi koi tum pooch leta h k ap theek nhi h tou mjhsa share krla, kabhi kuch kabhi kuch bhaeee

insaan ban jao tum

and batao rishta kab bhjo

bus bhool jao 
hamari baatein hamara darmiyaan h

mna kabhi kisi sa buraye nhi kri mehak sa sirf yahi kaha tha tumha smjhaye

and cmon yr flirt krna sa phla sochti tumha lagta h tum mjha use kro gi aur chali jao nice nice maham

cmon