Skip to main content

PyPostgreSQLWrapper is a simple adapter for PostgreSQL with connection pooling

Project description

PyPostgreSQLWrapper

PyPostgreSQLWrapper 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:

{
  "database": "postgres",
  "host": "localhost",
  "max_connection": 10,
  "password": "postgres",
  "port": 5432,
  "print_sql": true,
  "username": "postgres"
}

Usage

PyPostgreSQLWrapper usage description:

Delete

Delete with where

from py_postgresql_wrapper.database import Database

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

Delete with like condition

from py_postgresql_wrapper.database import Database

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

Insert

from py_postgresql_wrapper.database import Database

with Database() as database:
    database.insert('test').set('id', 1).set('description', 'Test').execute()

Paging

Paging with where

from py_postgresql_wrapper.database import Database

with Database() as database:
    database.select('test').fields('id', 'description').where('id', 3, operator='<').order_by('id').paging(0, 2)

Paging without where

from py_postgresql_wrapper.database import Database

with Database() as database:
    database.select('test').paging(0, 2)

Select

Fetch all

from py_postgresql_wrapper.database import Database

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

Fetch many

from py_postgresql_wrapper.database import Database

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

Fetch one

from py_postgresql_wrapper.database import Database

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

Select by file

from py_postgresql_wrapper.database import Database

with Database() as database:
    database.execute('find_test_by_id', {'id': 1}).fetch_one()

Select by query

from py_postgresql_wrapper.database import Database

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

SQL

from py_postgresql_wrapper.database import Database

with Database() as database:
    database.execute('''
        create table test (
            id int primary key,
            description varchar(255)
        )
    ''')

Update

Update with where

from py_postgresql_wrapper.database import Database

with Database() as database:
    database.update('test').set('description', 'New Test 1').where('id', 1).execute()

Update with where all

from py_postgresql_wrapper.database import Database

with Database() as database:
    database.update('test').set('description', 'New Test 1').where_all({'id': 1, 'description': 'Test 1'}).execute()

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_postgresql_wrapper-1.0.4-py2.py3-none-any.whl (19.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file py_postgresql_wrapper-1.0.4-py2.py3-none-any.whl.

File metadata

  • Download URL: py_postgresql_wrapper-1.0.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

File hashes

Hashes for py_postgresql_wrapper-1.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ca30f5a1e70088eb626160fdbfa165960330c89fefccd9f8b50efc699466989c
MD5 bdb44da2a0f3f00f9887305e557091cc
BLAKE2b-256 7e0c3799096515df080b857f40498017e043a513f516b03fcce07bdc2094f910

See more details on using hashes here.

Supported by

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