Skip to main content

Non ORM SQL Query runner

Project description

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


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

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

class UserDAO:
    """ some sort of database access object """
    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, "")

if __name__ == "__main__":

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 plwrap, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size plwrap-0.1.0.tar.gz (2.8 kB) File type Source Python version None 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