I have a problem insert to PostgreSQL.
The column I'm trying to insert is of type JSONB.
The type of the object is Counter()
.
In production it is working, but locally it raises the following error:
asyncpg.exceptions.DataError: invalid input for query argument $16: Counter({'clearmeleva': 1, 'cr7fragrance... (expected str, got Counter)
Thank you!
As stated in asyncpg documentation, the corresponding Python type for JSON
and JSONB
is a string
.
So if the column where you want to add your data is of type JSONB
, try to convert your Counter-type
object to a string
new_counter_type_obj = str(counter_type_obj)
and then pass it to asyncpg.