Skip to main content

Load CSV with header into PostgreSQL

Project description

Description

csv2postgresql imports data from a CSV file into PostgreSQL.

It differs from PostgreSQL COPY FROM ... WITH (FORMAT CSV ...) command as it detects automatically the CSV columns available, so even CSV files with missing columns or having columns arranged in a different order can be easily imported.

Setup

The software can be installed using pip or pipx, which is preferred.

pipx install csv2postgresql

Help

$ csv2postgresql --help
usage: csv2postgresql [-h] [--input-file INPUT_FILE] [--delimiter DELIMITER] [--quotechar QUOTECHAR]
                      [--escapechar ESCAPECHAR] [--encoding ENCODING]
                      dsn table

Load CSV with header into PostgreSQL

positional arguments:
  dsn
  table

optional arguments:
  -h, --help            show this help message and exit
  --input-file INPUT_FILE, -i INPUT_FILE
                        Input file name containing a valid CSV.
  --delimiter DELIMITER, -d DELIMITER
  --quotechar QUOTECHAR
  --escapechar ESCAPECHAR
  --encoding ENCODING, -e ENCODING

Example

csv2postgresql -i table.csv postgresql://user:password@localhost/db table

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

csv2postgresql-0.1.3.tar.gz (14.6 kB view hashes)

Uploaded Source

Built Distribution

csv2postgresql-0.1.3-py3-none-any.whl (15.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page