Skip to main content

shipyard-postgresql

PostgresClient is a Python class designed to facilitate interactions with PostgreSQL databases.

Installation

To use PostgresClient, you'll first need to install the required dependencies:

pip install shipyard-postgresql

Usage

Initialization

You can initialize a PostgresClient instance by providing the necessary connection parameters:

postgres = PostgresClient(
    user='your_username',
    pwd='your_password',
    host='your_host_address',
    port=5432,  # default PostgreSQL port
    database='your_database_name',
    schema='your_schema_name'  # optional, defaults to public
)

Methods

connect Establish an active connection to postgres. If this is not explicity called beforehand, it will be handled implicitly when the first database call is sent

postgres.connect()

execute_query

Execute a SQL query on the database connection:

postgres.execute_query('drop table if exists public.demo_table')

upload Upload data from a file to a PostgreSQL table:

file_path = 'path_to_your_file.csv'
table_name = 'your_table'
postgres.upload(file_path, table_name, insert_method = 'replace') # can also set to append

fetch Fetch data from the database using a SQL query and return the results as a pandas dataframe:

df = postgres.fetch('select * from public.demo_table limit 1000')

close Close the connection once finished

postgres.close()

Metadata

Release files for shipyard-postgresql 0.2.0

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

Source distribution (sdist)

Source distribution for shipyard-postgresql 0.2.0
File Size Uploaded
shipyard_postgresql-0.2.0.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shipyard-postgresql 0.2.0
File Interpreter ABI Platform
shipyard_postgresql-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.3 kB

Release files / shipyard_postgresql-0.2.0.tar.gz

Download URL shipyard_postgresql-0.2.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
97e398865a4e8207734b6e9f1e91c3869c4e735cfa11add636ba433cceaa5e71
BLAKE2b-256 checksum
How to use checksums
fd85c4ab82718a2fdd66968d50a6c292f4d1296761fb17ed9d3b381cb73d4bbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.9.18 Darwin/23.2.0

Release files / shipyard_postgresql-0.2.0-py3-none-any.whl

Download URL shipyard_postgresql-0.2.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d08fd4519e4e340402d68e646b52dffed5e72d75cf5b6d4efb15b7ace0af2814
BLAKE2b-256 checksum
How to use checksums
a8cfb2bd9aa4b849c752ece93987451c1d658ab5568429bff1d990260ee219db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.9.18 Darwin/23.2.0
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