The problem is that struct.unpack returns the result of the tuple, even if there is only one value to unpack. You need to make sure that you take the first element from the tuple, even if there is only one element. Otherwise, parsing psycopg2 sql will not try to convert the tuple to a string giving a "cannot adapt" error message.
impost psycopg2 con = connect(...) def save(long_blob): cur = con.cursor() long_data = struct.unpack('<L', long_blob)
source share