Skip to main content

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

Metadata

Release files for psql2csv 1.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for psql2csv 1.1.4
File Interpreter ABI Platform
psql2csv-1.1.4-py3-none-any.whl Python 3 none any Details

Release files / psql2csv-1.1.4-py3-none-any.whl

Download URL psql2csv-1.1.4-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3e13cfa1fad7754e2057711785a6993a4c42f6642060dec1203b06796013e61
BLAKE2b-256 checksum
How to use checksums
90403f83db8f1acae0c6f3ea40b94c96294ae35561a03fd2c8d0a0fa6b0a384b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.1.4 This release

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page