A local client for connecting and working with Postgresql Databases
Project description
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()
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 Distribution
Built Distribution
File details
Details for the file shipyard_postgresql-0.2.0.tar.gz
.
File metadata
- Download URL: shipyard_postgresql-0.2.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.9.18 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97e398865a4e8207734b6e9f1e91c3869c4e735cfa11add636ba433cceaa5e71 |
|
MD5 | 7f6cb89edb58849d311793a3c4cf87a0 |
|
BLAKE2b-256 | fd85c4ab82718a2fdd66968d50a6c292f4d1296761fb17ed9d3b381cb73d4bbd |
File details
Details for the file shipyard_postgresql-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: shipyard_postgresql-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.9.18 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d08fd4519e4e340402d68e646b52dffed5e72d75cf5b6d4efb15b7ace0af2814 |
|
MD5 | e5bb0876ba0632d3022b9148cd3c12de |
|
BLAKE2b-256 | a8cfb2bd9aa4b849c752ece93987451c1d658ab5568429bff1d990260ee219db |