I ran across this bug three times today in one of our projects. Putting the problem and solution online for future reference.
impost psycopg2
con = connect(...)
def save(long_blob):
cur = con.cursor()
long_data = struct.unpack('<L', long_blob)
cur.execute('insert into blob_records( blob_data ) values (%s)', [long_data])
This will fail with the error "can't adapt" from psycopg2.