Skip to main content

Psycopg wrapper

Project description

Moliere

psycopg2-binary wrapper for easy application integration (e.g. flask web sites).

Installation

$ pip install moliere

Usage

import moliere

# Creating instance.
db = moliere.Pgdb()

# Connecting to database.
db.connect(host, db_name, user, pwd)

# Query execution. Return list of dicts (psycopg2 RealDictCursor).
result = db.execute(
  'SELECT * FROM table WHERE id>%(id)s;',
  {
    'id': 7
})

# Closing connection.
db.disconnect()

Automatic connection

While create instance Moliere try to find environment variables with endings DB_HOST, DB_NAME, DB_USER and DB_PWD. If it success connection will create automatically.
Also it have builtin instance of Pgbd named DB_OBJ, so if you have necessary environment variables you can use package like this:

from moliere import DB_OBJ

result = DB_OBJ.execute(
  'SELECT * FROM table WHERE id>%(id)s;',
  {
    'id': 7
})

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 Moliere, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size Moliere-0.0.5-py3-none-any.whl (3.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size Moliere-0.0.5.tar.gz (2.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page