Skip to main content

A small module for working quickly with the PostgreSQL

Project description

About

A small module for working quickly with the PostgreSQL

Simple Start for home project

  1. Install package from pip
pip install postgresqlconnector
  1. Use connector
from postgresqlconnector import DB
print(DB.query('''select * from pg_stat_activity'''))

API

query

Get all rows from your sql query

Param:

  • sql: str - Your query
  • params: dict - Params for query

Result:

  • Array of Record
result = DB.query('''select * from pg_stat_activity''')
print(result[0])
print(result[0].pid)

row

Get first row from your sql query

Param:

  • sql: str - Your query
  • params: dict - Params for query

Result:

  • Record
result = DB.row('''select * from pg_stat_activity''')
print(result.pid)

scalar

Get first column from first row from you sql query

Param:

  • sql: str - Your query
  • params: dict - Params for query

Result:

  • Scalar
result = DB.scalar('''select pid, * from pg_stat_activity''')
print(result)

set_connection_info

Set database connections

Param:

  • host: str = 'localhose' - Host
  • port: str = '5432' - Port
  • dbname: str = 'postgres' - Database name
  • user: str = 'postgres' - User
  • password: str = 'postgres' - Password

create_transaction

Work with transaction.

If an exception occurs in your code, the transaction will rollback

with DB.create_transaction():
    # block for your code

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

postgresqlconnector-0.6.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file postgresqlconnector-0.6.tar.gz.

File metadata

  • Download URL: postgresqlconnector-0.6.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for postgresqlconnector-0.6.tar.gz
Algorithm Hash digest
SHA256 798450aa98ded759bcab4a3569ebb094ed664935cc9bc0b7acee726ef89d7049
MD5 d9bb9b3bee915f7ac7d838199c6910d7
BLAKE2b-256 dd64e77ca2244336476c40a7943fb48c6d1bae8ddcb0c905f4b4ff6672656203

See more details on using hashes here.

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