-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
binary representation of numpy.complex and postgresql composite #1060
Comments
This is because a composite type isn't a "scalar" and requires specific representation on the wire. Ideally, asyncpg should learn to support await conn.set_type_codec(
'complex',
schema='public',
encoder=lambda x: (x.real, x.imag),
decoder=lambda t: np.complex64(t[0] + 1j * t[1]),
format='tuple',
) |
elprans
added a commit
that referenced
this issue
Aug 15, 2023
It is now possible to `set_type_codec('mycomposite', ... format='tuple')`, which is useful for types that are represented by a composite type in Postgres, but are an integral type in Python, e.g. `complex`. Fixes: #1060
thanks a lot, I can't wait for this update :) |
elprans
added a commit
that referenced
this issue
Aug 16, 2023
It is now possible to `set_type_codec('mycomposite', ... format='tuple')`, which is useful for types that are represented by a composite type in Postgres, but are an integral type in Python, e.g. `complex`. Fixes: #1060
elprans
added a commit
that referenced
this issue
Aug 17, 2023
It is now possible to `set_type_codec('mycomposite', ... format='tuple')`, which is useful for types that are represented by a composite type in Postgres, but are an integral type in Python, e.g. `complex`. Fixes: #1060
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the issue with a local PostgreSQL install?:
uvloop?: yes
Hi,
I need for a project to store complex numbers in a database (numpy.complex64 exactly) and for that I created a postgresql composite datatype.
I was able to make it work with asyncpg in text format for simple INSERT, SELECT... after some works and patches found on previous issues report.
However for the binary format I have weird errors : asyncpg.exceptions.DatatypeMismatchError: wrong number of columns: 1082549862, expected 2
I made a "simple" python script to reproduce the issue :
The text was updated successfully, but these errors were encountered: