Import Data from CSV into Postgres

Version: v2.x

Introduction

You might have existing data stored in a CSV file that you need to import into your Postgres database. The following guide will show how to do so.

Let's assume we have the following CSV file, which is named profile.csv:

Step 1: Add a corresponding table to your PG database

Let us create a table to match the data structure in your CSV file.

Step 2: Connect to your Postgres database

Connect to your Postgres database by using the psql command on the terminal:

Step 3: Import the data from the CSV file

Once connected to the database, use the following command from inside psql to import the data:

Your data would have been successfully copied into the Postgres database.

What did you think of this doc?

Last updated