A library and a CLI to download PostgreSQL schemas and tables
Project description
psql2csv
A library and a CLI to download PostgreSQL schemas and tables
Installation
pip3 install psql2csv
Usage
CLI
To run the CLI normally, just run
psql2csv
Options:
--dbname TEXT The database name
--host TEXT URL Endpoint of the database
--user TEXT Login username
--password TEXT Login password
--all Downloads everything
--schema Downloads a schema
--table Downloads a table
--stdout Whether to print which schema and table is downloading
--help Show this message and exit.
API
There are 3 runnable functions: * download_all * download_schema * download_table
download_all
download_all(conn, output_folder=‘output’, exclude_schemas=[‘pg_toast’, ‘pg_temp_1’, ‘pg_toast_temp_1’, ‘pg_catalog’, ‘public’, ‘information_schema’], stdout=False)
Downloads all schemas and all its tables by specifying schema
conn: input connection or psql2csv.DataBase. If it’s an input connection, it’ll eventually be converted to psql2csv.DataBase class
output_folder: the name of the folder to place the data
exclude_schemas: Which schemas to exclude while downloading everything
stdout: whether to print which schema and table is downloading. True = print
download_schema
download_schema(conn, schema, output_folder=‘output’, stdout=False)
Downloads schema and its tables by specifying schema
conn: input connection or psql2csv.DataBase. If it’s an input connection, it’ll eventually be converted to psql2csv.DataBase class
schema: name of the schema to download
output_folder: the name of the folder to place the data
stdout: whether to print which schema and table is downloading. True = print
download_table
download_table(conn, schema, table, output_folder=‘output’, stdout=False)
Downloads table by specifying schema and table
conn: input connection or psql2csv.DataBase. If it’s an input connection, it’ll eventually be converted to psql2csv.DataBase class
schema: name of the schema that the table belongs to
table: name of the table to download
output_folder: the name of the folder to place the data
stdout: whether to print which table is downloading. True = print
Versions
1.1.x
Added CLI
1.0.x
First publish
Project details
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
File details
Details for the file psql2csv-1.1.4-py3-none-any.whl
.
File metadata
- Download URL: psql2csv-1.1.4-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3e13cfa1fad7754e2057711785a6993a4c42f6642060dec1203b06796013e61 |
|
MD5 | a0dc84fc709e3cef048681395ab64975 |
|
BLAKE2b-256 | 90403f83db8f1acae0c6f3ea40b94c96294ae35561a03fd2c8d0a0fa6b0a384b |