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.

Source Distribution

Moliere-0.0.5.tar.gz (2.3 kB view hashes)

Uploaded Source

Built Distribution

Moliere-0.0.5-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

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