Skip to main content

PLWRAP - asyncpg

plwrap is an easy to use wrapper for Postgresql orientend on jdbi. It is not an ORM, instead it allows to run SQL queries and dump the result into consistent Python Objects (Dataclasses are prefered)

SQL is awesome. Try to remember! :-)

Sanic integration

When used together with sanic, plwrap uses the sanic logging framework for debugging queries

Examples

import asyncio
from dataclasses import dataclass
import asyncpg
from plwrap import query, one

@dataclass
class User:
    """ User store """
    id: str
    email: str
    pwhash: str


class UserDAO:
    """ some sort of database access object """
    @staticmethod
    @one
    @query(User)
    async def get_by_email(email: str) -> User:
        """ Tries to get a user based on its email (unique) """
        return "select id, email, pwhash from users where email = $1", email


async def main():
    db_pool = await asyncpg.create_pool(database="what", user="ever")

    user = await UserDAO.get_by_email(db_pool, "me@xvzf.tech")
    print(user)

if __name__ == "__main__":
    asyncio.get_event_loop().run_until_complete(main())

Release files for plwrap 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for plwrap 0.1.0
File Size Uploaded
plwrap-0.1.0.tar.gz 2.8 kB Details

Release files / plwrap-0.1.0.tar.gz

Download URL plwrap-0.1.0.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b82b746c318a2d2c1bd48945226afe6b996cc8de0d79102c0bfb4eee8c14f9d2
BLAKE2b-256 checksum
How to use checksums
a4c5f4fa0042ea79b2fff2c8636c70d19788601cd32f5d99af1c4eb0a21c55bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page