Sqlite: read hex-stored strings
I keep having to search this, so here it is for myself.
If you have some sqlite data (say, for Luanti) that is not so easy to read when viewing the sqlite database directly, there are still some options. The proper way to do it is to use CAST(columnname as text) pretty_name_here.
sqlite> SELECT * FROM entries WHERE modname LIKE '%balloon%' ; ╭──────────────────┬─────────────────────────────────────┬──────────────────────────────────────────────────────────╮ │ modname │ key │ value │ ╞══════════════════╪═════════════════════════════════════╪══════════════════════════════════════════════════════════╡ │'hot_air_balloons'│x'616273656e745f62616c6c6f6f6e657273'│x'72657475726e207b73696e676c65706c617965723d22686f745f6169│ │ │ │725f62616c6c6f6f6e733a62616c6c6f6f6e227d' │ ╰──────────────────┴─────────────────────────────────────┴──────────────────────────────────────────────────────────╯
If you set the output mode to column or csv, it will decode those already for you.
sqlite> .mode column sqlite> SELECT * FROM entries WHERE modname LIKE '%balloon%' ; modname key value ---------------- ----------------- ------------------------------------------------ hot_air_balloons absent_ballooners return {singleplayer="hot_air_balloons:balloon"} sqlite> SELECT modname, CAST(key as text) key, CAST(value as text) value FROM entries WHERE modname LIKE '%balloon%' ; modname key value ---------------- ----------------- ------------------------------------------------ hot_air_balloons absent_ballooners return {singleplayer="hot_air_balloons:balloon"}
Comments