Metadata-Version: 2.1
Name: csv2postgresql
Version: 0.1.2
Summary: Load CSV with header into PostgreSQL
License: GPL-3.0-or-later
Author-email: Francesco Frassinelli <francesco.frassinelli@nina.no>
Requires-Python: >=3.7
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: psycopg2-binary~=2.9
Project-URL: homepage, https://github.com/NINAnor/csv2postgresql
Project-URL: repository, https://github.com/NINAnor/csv2postgresql
Description-Content-Type: text/markdown

# 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
```
