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
conn=asyncpg.connect(...)
conn.execute('INSERT INTO users (user_info) VALUES ($1)', data) # WRONG
So I have to convert it to tuple, like this:
tuple_data=data['name'], data['surname'], data['alias']
conn.execute('INSERT INTO users (user_info) VALUES ($1)', tuple_data)
But that conversion requires me to mimic field order of postgre composite in python code, or else inserted data will be messed up.
Is there a way to insert composite column represented as key-value pairs in your code without using explicit knowledge of composite's field order?
As far as I understand, asyncpg has introspection of postgre types anyway, so maybe field order of composite types is presented inside asyncpg meta information already - so that asyncpg clients can use it?
The text was updated successfully, but these errors were encountered:
This allows asyncpg to take an arbitrary mapping as input for composite
types, as long as the keys match composite type fields.
This allows removing some tedium when handling complex composite types.
Fixes: #349.
This allows asyncpg to take an arbitrary mapping as input for composite
types, as long as the keys match composite type fields.
This allows removing some tedium when handling complex composite types.
Fixes: #349.
Is there a way to do subj?
In Postgre, I have a table with composite type, like this:
In Python, I have dict reflecting composite type, like this:
I can't use this dict in query directly:
So I have to convert it to tuple, like this:
But that conversion requires me to mimic field order of postgre composite in python code, or else inserted data will be messed up.
Is there a way to insert composite column represented as key-value pairs in your code without using explicit knowledge of composite's field order?
As far as I understand, asyncpg has introspection of postgre types anyway, so maybe field order of composite types is presented inside asyncpg meta information already - so that asyncpg clients can use it?
The text was updated successfully, but these errors were encountered: