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.

Files for postgresqlconnector, version 0.6
Filename, size File type Python version Upload date Hashes
Filename, size postgresqlconnector-0.6.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page