abstract kitchen

How to Import CSV Files to PostgreSQL

by Dmitry

Sometimes I need to upload large CSV files to PostgreSQL. CSV file might have hundreds of columns, that's why i want a tool that can do some magic for me. My main goal is to be able to review a bunch of data. Execute some SQL-requests and decide what to do next with it.

A nice tool to handle this is pgfutter.

Usage example:
./pgfutter csv file.csv --db mydatabase

It will automatically create all columns and fill them with data. The table name will be name of the file. If you want custom table name, do this:

./pgfutter csv file.csv --db mydatabase  --table mytable

For more use cases, visit project GitHub. If you want to import CSV to existing PostgreSQL table, check COPY.

Get my latest articles in your inbox.