0

When running sql script to view data on Cexplorer database, many times,I see binary data. for example, multi_asset.name, multi_asset.policy in the following query.

enter image description here

Is there any way to view these data in normal text?

Thanks very much.

2 Answers 2

1

These fields are not in general "normal text". They might be normal text (eg ASCII) or they could also be UTF-8 or UTF-16 or any other encoding.

The most sensible way to view them is as hexadecimal and that is what the psql command line does. Eg:

$ psql cexplorer
psql (14.5 (Debian 14.5-1), server 13.7 (Debian 13.7-0+deb11u1))
Type "help" for help.

cexplorer=# select * from multi_asset limit 1 ; 
 id |                           policy                           |       name       |                 fingerprint                  
----+------------------------------------------------------------+------------------+----------------------------------------------
  1 | \x00000002df633853f6a47465c9496721d2d5b1291b8398016c0e87ae | \x6e7574636f696e | asset12h3p5l3nd5y26lr22am7y7ga3vxghkhf57zkhd
(1 row)

So it you want something that is guaranteed to be "normal text" you should use the fingerprint field, which is Bech32 encoded.

3
  • Thank you very much. Is there anyway to do like this on PgAmin?
    – cdt
    Aug 21, 2022 at 22:53
  • Sorry, no idea. I have never used PgAdmin. Aug 21, 2022 at 22:55
  • Thanks you very much. It is very helpful to me.
    – cdt
    Aug 21, 2022 at 23:20
1

in your case:

SELECT multi_asset.policy::text human_policy FROM ...

or

SELECT encode(multi_asset.name::bytea, 'escape'::text) human_name FROM ... 
1
  • thanks a lot. For me, it is the easiest way.
    – cdt
    Aug 25, 2022 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.