Sqlite: How to cast(data as TEXT) for BLOB

前端 未结 2 960
[愿得一人]
[愿得一人] 2020-12-17 14:19

I have a sqlite database from which I want to extract a column of information with the datatype BLOB. I am trying this:

SELECT cast(data as TEXT) FROM content<

2条回答
  •  無奈伤痛
    2020-12-17 14:36

    You can use

    SELECT hex(data) FROM content
    

    or

    SELECT quote(data) FROM content
    

    The first will return a hex string (ABCD), the second quoted as an SQL literal (X'ABCD').

    Note that there's (currently) no way of converting hexadecimal column information back to a BLOB in SQLite. You will have to use C/Perl/Python/… bindings to convert and import those.

提交回复
热议问题