Import/export CSV files efficiently to/from a Postgresql database.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
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?
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file csv_pg-0.1.0-py3-none-any.whl.
File metadata
- Download URL: csv_pg-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78cd622ce39cc4d0b40f3de367288c69e253102270cda738ce343d5af735edc8
|
|
| MD5 |
18cd1d25c0657b247126077afa46c4ef
|
|
| BLAKE2b-256 |
a9ded05cbe9e1d48eab67dc50a9bccc5690212e686dd4349e7137efe2b17ddae
|