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 requires PDM to run.
pdm install --no-self
Help
$ pdm run python csv2postgresql.py --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
pdm run python csv2postgresql.py -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.0.tar.gz
(2.3 kB
view hashes)
Built Distribution
Close
Hashes for csv2postgresql-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9888931ba1f534d9e6945e7521388249ac47e0843ce5acadf76551fe47b0a9a |
|
MD5 | 75c7615294a15590fd63d45baab4c777 |
|
BLAKE2b-256 | 2114b1c3f983af8d20f6b8c9e3a9a1a0341ba72fb301adb26d67bbb0e46bec0f |