Skip to main content

Making psycopg2 a little simpler to use.

Project description

Making psycopg2 a little simpler to use.

Usage:

from psyshort import Psyshort
psy = Psyshort(
    hostname="db.example.com",
    dbname="example_database",
    username="postgres_user",
    password="pa$$w0rd"
    )
select = psy.select(
    table="my_table", # Table's name (mandatory).
    fields=[
        "id",
        "first_name",
        "last_name",
        "phone",
        ], # Fields to include in the result (optional).
    where="last_name = 'Smith'", # Select only rows where last_name = 'Smith' applies (optional).
    limit=1000, # Limit result to 1000 records (optional).
    order_by="first_name" # Order the result by 'first_name' column (optional).
    )
result = select["result"] # The selected records.
duration = select["duration"] # The duration of the operation.

psy.insert(
    table="my_table", # Table's name (mandatory).
    columns=[
        "first_name",
        "last_name",
        "phone",
        ], # Columns by which to insert values (mandatory).
    row={
        "first_name": "John",
        "last_name": "Smith",
        "phone": "KL5-2390"
        } # Row to insert to the table (mandatory).
    )

psy.disconnect() # Occurs on psy.__del__

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

psyshort-0.1.6.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

psyshort-0.1.6-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page