Skip to main content

Simple decorator for multiprocessing and psql insertion

Project description

gerardo

PyPI version

gerardo provides decorators to easily compute in parallel and store the results in a PostgreSQL database.

Usage

See examples/example.py for more details.

from gerardo import psql_mp_insert, psql_handler

# Set a PostgreSQL handler
pghost = os.environ["PGHOST"]
DSN = {
    "host": pghost,
    "port": "",
    "user": "",
    "password": "",
    "dbname": "example_db",
}
PSQL_TABLE = "test_table"
COLUMNS = [('x', 'INT'), ('y', 'INT')]

PH = psql_handler(DSN, PSQL_TABLE, COLUMNS)

# Define a single-variable function.
@psql_mp_insert(PH)
def f(x):
    return (x[0]+x[1], x[0]*x[1])

# Compute by forming a list of arguments
list_args = [(x, y) for x in range(5) for y in range(10)]
f(list_args)

Installation

pip install gerardo --user

Homepage

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

Supported by

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