Skip to main content

Bottle PostgreSQL

PyPI - License PyPI - Version

Bottle PostgreSQL is a simple adapter for PostgreSQL with connection pooling.

Configuration

The configuration can be done through JSON file or by Dict following the pattern described below:

{
  "connect_timeout": 30,
  "dbname": "postgres",
  "host": "localhost",
  "maxconnections": 5,
  "password": "postgres",
  "port": 5432,
  "print_sql": true,
  "user": "postgres
}

Create the queries directory. This should contain all the .sql files that the library will use.

Usage

PyPostgreSQLWrapper usage description:

Delete

Delete with where

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .delete('test')
        .where('id', 1)
        .execute()
    )

Delete with where condition

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .delete('test')
        .where('description', 'Test%', operator='like')
        .execute()
    )

Execute

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .execute(
            '''
                create table if not exists test (
                    id bigserial not null,
                    name varchar(100),
                    description varchar(255),
                    constraint test_primary_key primary key (id)
                )
            ''',
            skip_load_query=True
        )
    )

Insert

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .insert('test')
        .set('id', 1)
        .set('name', 'Name')
        .set('description', 'Description')
        .execute()   
    )

Paging

Paging with where condition

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .select('test')
        .fields('id', 'name', 'description')
        .where('id', 1, operator='>')
        .order_by('id')
        .paging(0, 2)
    )

Paging without where condition

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .select('test')
        .paging(0, 10)
    )

Select

Fetch all

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .select('test')
        .execute()
        .fetch_all()   
    )

Fetch many

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .select('test')
        .execute()
        .fetch_many(1)
    )

Fetch one

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .select('test')
        .execute()
        .fetch_one()
    )

Select by file

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .execute('find_by_id', {'id': 1})
        .fetch_one()
    )

Select by query

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .execute('select id, name, description from test where id = %(id)s', {'id': 1})
        .fetch_one()
    )

Update

Update with where

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .update('test')
        .set('name', 'New Name')
        .set('description', 'New Description')
        .where('id', 1)
        .execute()   
    )

Update with where all

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .update('test')
        .set('name', 'New Name')
        .set('description', 'New Description')
        .where_all({'id': 1, 'name': 'Name', 'description': 'Description'})
        .execute()
    )

Using filters

SQL

select
    id,
    name,
    description
from test
where 1 = 1
{{#id}}
and id = %(id)s
{{/id}}
{{#id}}
and name like %(name)s
{{/id}}

Select with filters

from bottle_postgresql import Database

with Database() as connection:
    (
        connection
        .execute('test.find_all_with_filter', parameters={'id': 1, 'name': 'Name'})
        .fetch_one()
    )

Metadata

Release files for bottle-postgresql 1.0.1

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 bottle-postgresql 1.0.1
File Interpreter ABI Platform Actions
bottle_postgresql-1.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for bottle_postgresql-1.0.1-py2.py3-none-any.whl

Release files / bottle_postgresql-1.0.1-py2.py3-none-any.whl

Download URL bottle_postgresql-1.0.1-py2.py3-none-any.whl
Size 6.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ee1a97dc884348e85a097072ab404fdc6660fb5f8cc19ac152223cd2539756a3
BLAKE2b-256 checksum
How to use checksums
5fbe146e8e0df819166105a4cede5747a37b58883ec64c78f9ba04262692e6c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Security for bottle-postgresql 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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