Sqlite:如何为BLOB强制转换(数据为TEXT) [英] Sqlite: How to cast(data as TEXT) for BLOB

查看:1049
本文介绍了Sqlite:如何为BLOB强制转换(数据为TEXT)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个sqlite数据库,要从中提取一列数据类型为BLOB的信息。我正在尝试:

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

从内容中选择演员(数据为文本)

这显然不起作用。输出是这样的乱码文本:

This is obviously not working. The output is garbled text like this:

x Uak 0? > 8 0Ff;I. 。 i׮% A s M

内容列中的数据主要是文本,但也可能有图像(我如果我强制转换为TEXT,则可能会导致问题)。我只是想将这些数据提取为可用格式。有任何想法吗?

The data in the content column is mostly text, but may also have images (which I recognized could cause a problem if I cast as TEXT). I simply want to extract that data into a usable format. Any ideas?

推荐答案

您可以使用

SELECT hex(data) FROM content

SELECT quote(data) FROM content

第一个将返回一个十六进制字符串( ABCD ),第二个将被引用为SQL文字( X'ABCD')。

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

(目前)无法在SQLite中将十六进制列信息转换回BLOB。您将必须使用C / Perl / Python /…绑定来转换和导入这些绑定。

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.

这篇关于Sqlite:如何为BLOB强制转换(数据为TEXT)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆