You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: n/a
Python version: 3.9
Platform: MacOS and Linux
Do you use pgbouncer?: no
Did you install asyncpg with pip?: yes
If you built asyncpg locally, which version of Cython did you use?: n/a
Can the issue be reproduced under both asyncio and uvloop?: n/a
Hello - I was wondering if it's possible to access the provided codecs for types such as Range at runtime?
Use-case: I'd like to pass my objects in as a JSON array rather than an array of composite types. However, one field is a Range type, which isn't json-encodable by default. I was hoping to use your optimized encoders when we encounter such types.
The text was updated successfully, but these errors were encountered:
import asyncpg
from asyncpg import range as asyncpg_range
# Define a custom encoder function for the Range type
def encode_range(range_obj):
return f"[{range_obj.lower},{range_obj.upper})"
# Register the custom codec
asyncpg_range.Range._binary_encoder = encode_range
# Create a connection pool with the custom codec
async def create_db_pool():
pool = await asyncpg.create_pool(
dsn="postgres://....",
host="....amazonaws.com",
user="xxx",
database="yyy",
port="5432",
password="12345"
)
return pool
the issue with a local PostgreSQL install?: n/a
uvloop?: n/a
Hello - I was wondering if it's possible to access the provided codecs for types such as Range at runtime?
Use-case: I'd like to pass my objects in as a JSON array rather than an array of composite types. However, one field is a Range type, which isn't json-encodable by default. I was hoping to use your optimized encoders when we encounter such types.
The text was updated successfully, but these errors were encountered: