AsyncPGPromise
Motivation
The creation of AsyncPGPromise was primarily driven by an aspiration to bring the clean API and named arguments support, common in Node.js' `pg-promise``, to the Python ecosystem. The lack of such an approach in Python became more pronounced upon transitioning from Node.js, sparking the motivation to develop a solution. With Python's ultra-fast writing mold being a major encouraging factor, this tiny wrapper, AsyncPGPromise, was brought into existence to fill this gap and to provide a sleek and efficient means of handling PostgreSQL database operations.
Features
- Simplicity: By using named arguments in your SQL queries, you can keep your code clean and readable.
- Flexibility: All the power of the
asyncpglibrary is still at your fingertips, with additional convenience provided by AsyncPGPromise.
Installation
pip install asyncpgpromise
Getting Started
You can create a new AsyncPGPromise instance with an existing asyncpg connection object:
from asyncpgpromise import AsyncPGPromise
import asyncpg
# First create an asyncpg connection
conn = await asyncpg.connect(user='user', password='password', database='database', host='127.0.0.1')
# Then pass it to AsyncPGPromise
pg = AsyncPGPromise(conn)
Usage
Querying
You can perform SQL queries with named arguments:
rows = await pg.query('SELECT * FROM users WHERE name = $name', name='John')
The query method returns a list of dictionaries, each representing a row from the SQL query.
Fetching One Row
If you're only expecting a single row result, you can use the one method:
row = await pg.one('SELECT * FROM users WHERE id = $id', id=1)
Note
This is a new project and may still have some rough edges. Contributions are very welcome!
To-Do
- Parsing of fields with JSON data
License
AsyncPGPromise is available under the MIT license. See the LICENSE file for more info.
Metadata
Release files for asyncpgpromise 0.1.4
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 | Actions |
|---|---|---|---|---|
| asyncpgpromise-0.1.4.tar.gz | 2.8 kB | Without provenance | Details for asyncpgpromise-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asyncpgpromise-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for asyncpgpromise-0.1.4-py3-none-any.whl |
Total release size: 5.8 kB
Release files / asyncpgpromise-0.1.4.tar.gz
| Download URL | asyncpgpromise-0.1.4.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f751711a0da6722abc3eea5203608dbaa762b1bebd9f8c3a8767f85d61beaa0d
|
|
BLAKE2b-256 checksum How to use checksums |
6a7767c941231354d5409cfa7f3c00e80a9eb56c64de61882fb0184cae519d61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / asyncpgpromise-0.1.4-py3-none-any.whl
| Download URL | asyncpgpromise-0.1.4-py3-none-any.whl |
|---|---|
| Size | 3.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d886520574bcbb050d5f8f123b78e4dab93816dbf8d139a1c4515b8b6934fbb
|
|
BLAKE2b-256 checksum How to use checksums |
c6b5477faa312d801748dd395a891cd60d79fc76b1b953d24253a059aa5815b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for asyncpgpromise 0.1.4
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.