Archived
This project has been archived by its maintainers, and is no longer receiving any updates.
csv_pg
A Python module to import/export CSV files efficiently to/from a Postgresql database.
Key features:
- Detect CSV file dialect automatically
- Create target database table automatically
- Handle localized date/time and decimal formats
- Filter CSV file rows during import
Usage examples
Installation:
pip install csv_pg
Import CSV file tests/samples/misc.csv to table misc (recreate table if already exists):
python -m csv_pg from_csv tests/samples/misc.csv --recreate
Export table misc to CSV file misc.local.csv (recreate file if already exists):
python -m csv_pg to_csv misc.local.csv misc --recreate
Contributors guidelines
Prepare environment:
# Debian: sudo apt install libpq-dev
python -m venv .venv # Debian: python3 -m venv .venv
.\.venv\Scripts\activate # Linux: source .venv/bin/activate
pip install .[dev]
Create test database:
sudo -u postgres createdb -E UTF8 -l fr_FR.UTF8 -T template0 test_csv_pg
Run tests:
python -m unittest
Alternatives / inspirations
-
- Have to manually call Postgresql COPY command?
-
- Depends on Django, and force import to a Django model (cannot simply load to a temporary table)
- No filter during import?
Metadata
Release files for csv-pg 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| csv_pg-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / csv_pg-0.1.0-py3-none-any.whl
| Download URL | csv_pg-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78cd622ce39cc4d0b40f3de367288c69e253102270cda738ce343d5af735edc8
|
|
BLAKE2b-256 checksum How to use checksums |
a9ded05cbe9e1d48eab67dc50a9bccc5690212e686dd4349e7137efe2b17ddae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.2
|