Skip to main content

A simple and fast cli application to load a csv into postgres

Project description

csv2pg

A simple and fast cli application to load a csv into postgres

Installation

pip install csv2pg

Usage

csv2pg --help

csv2pg expects the same parameter than psql to setup the postgres connection

# Loading data.csv into public.my_table
csv2pg -h localhost -p 5432 -U postgres -d postgres public.my_table data.csv --verbose
# Using postgres env to set connection variables
PGHOST=mypg.host.com PGPORT=5432 PGDATABASE=mydb PGUSER=myuser csv2pg public.my_table data.csv --verbose

Dialect discovery

With python csv.Sniffer() class the csv parameters like delimiter, quotechar, escapechar, lineterminator are automatically detected. They can be overriden with cli options.

Basic database utilities

csv2pg will automatically create the table using the header of the csv file. Caution, the option --overwrite will drop the table before inserting the new records in.

Project details


Download files

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

Files for csv2pg, version 1.0.0b2
Filename, size File type Python version Upload date Hashes
Filename, size csv2pg-1.0.0b2.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page