I'm using Python's struct.pack
function to pack various data types into a common 32-bit integer field in PostgreSQL. The drawback is that I can't operate with these values in the database, I have to perform a struct.unpack
in Python on the data to know what it represents.
If I pack a 32-bit float into this field, is there any way to get PostgreSQL to do the conversion for me?
I tried this but it didn't work:
select cast(cast(value as bit(32)) as float4) ...
It will successfully cast the integer to bit(32) but it won't convert that back to a float.