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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file csv2postgresql-0.1.3.tar.gz.

File metadata

  • Download URL: csv2postgresql-0.1.3.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for csv2postgresql-0.1.3.tar.gz
Algorithm Hash digest
SHA256 cbd168e6ebf7a64cffa8acba0c8d9581c361a25813a5568bb6fb041428560b81
MD5 82358d14753fe70f726b8c5818df7d6b
BLAKE2b-256 73d2ec99726031832cf302c695a8571d01d704e77d776769d168c088f391f9ae

See more details on using hashes here.

File details

Details for the file csv2postgresql-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: csv2postgresql-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for csv2postgresql-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b0af3eb61a6d86fb000b4553c0b9db407cdf3cb52cb26981cc897743ba509faa
MD5 bd72091a93037552ccb61530abd4484e
BLAKE2b-256 2708ea27b0f65a13dfdd011ea9522f1b073c51aa67c2633c19efdfc4b4833941

See more details on using hashes here.

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