Search code examples
python-3.6psycopgasyncpg

Is there a register_adapter (found in psycopg) equivalent function in asyncpg


Do we have to register adapters in asyncpg for executing queries, just like in psycopg?

http://initd.org/psycopg/docs/extensions.html#psycopg2.extensions.register_adapter


Solution

  • Found out that set_type_codec are used here. They are much easier and doesn't require type introspections.

    Here are some good references: https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.connection.Connection.set_type_codec

    https://github.com/MagicStack/asyncpg/blob/master/docs/usage.rst#custom-type-conversions

    https://github.com/MagicStack/asyncpg/issues/242