Cauldron is an asyncio based library that removes boilerplate code when using databases. Currently it supports using postgresql and redis.
Requirements
Python >= 3.4.3
Installation
To install via pip:
$ pip install cauldron
To install from source:
$ git clone https://github.com/nerandell/cauldron
$ cd cauldron
$ python setup.py install
Usage
Cauldron currently supports postgres and redis. It uses aiopg and aioredis internally but removes a lot of boilerplate code that is usually written.
Sample code using aiopg:
import asyncio
from aiopg.pool import create_pool
dsn = 'dbname=jetty user=nick password=1234 host=localhost port=5432'
class UsePostgres():
@classmethod
def test_select(cls):
pool = yield from create_pool(dsn)
with (yield from pool) as conn:
cur = yield from conn.cursor()
yield from cur.execute('SELECT 1')
ret = yield from cur.fetchone()
assert ret == (1,), ret
Using Cauldron:
from cauldron import PostgresStore
class UseCauldron(PostgresStore):
@classmethod
def test_select(cls):
rows = yield from cls.raw_query('select 1')
print(rows)
Other Examples
cauldron also supports using different cursors in a way that you have to write minimal code.
Using default cursor
from cauldron import PostgresStore
class UseCauldron(PostgresStore):
@classmethod
@cursor
def test_select(cls, cur):
rows = yield from cls.raw_sql('select * from users')
print(rows)
Using namedtuple cursor
from cauldron import PostgresStore
class UseCauldron(PostgresStore):
@classmethod
@nt_cursor
def test_select(cls, cur):
rows = yield from cls.raw_sql('select * from users')
print(rows)
Using dict cursor:
from cauldron import PostgresStore
class UseCauldron(PostgresStore):
@classmethod
@dict_cursor
def test_select(cls, cur):
rows = yield from cls.raw_sql('select * from users')
print(rows)
cauldron also provides functionalities for common DB operations to make your code more readable
Inserting into db:
from cauldron import PostgresStore
class UseCauldron(PostgresStore):
@classmethod
def store_user(cls, username, password):
insert_dict = {'username': username, 'password': password}
yield from cls.insert('user_table', insert_dict)
License
cauldron is offered under the MIT license.
Source code
The latest developer version is available in a github repository: https://github.com/nerandell/cauldron
Metadata
Release files for cauldron 1.0.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cauldron-1.0.14.tar.gz | 5.3 kB | Without provenance | Details |
Release files / cauldron-1.0.14.tar.gz
| Download URL | cauldron-1.0.14.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f548946fdefae11a82ff95426e2061989c4a9a97e518c769efb106b74842606
|
|
BLAKE2b-256 checksum How to use checksums |
c06a35aa62b60e752c8fd207dadeefcc6ebe95a9ac3aad8114451d7af4b1aa8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for cauldron 1.0.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.