MagicStack / MagicStack/asyncpg

Add equivalent to psycopg2 `register_adapter`

Open
#1,186 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.1k
Forks
468
PR merge metrics
No merged PRs in 30d

Description

In psycopg2, `register_adapter` along with utility functions provides a useful way to map custom Python classes into valid representations, often by relatively simple behaviors such as casting to `str`. There is no equivalent in asyncpg meaning moving from psycopg2 to asyncpg requires adding lots of `str()` casts to add and select queries.

The closest equivalent is `set_type_codec` but this only works for types that are registered with Postgres, not custom Python classes.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing asyncpg's existing set_type_codec support and psycopg2's register_adapter behavior. Determine how custom Python classes should be represented for query parameters without requiring PostgreSQL types, and define completion around equivalent add and select behavior without manual str() casts.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.