我正在将一些使用MySQL的工具转换为PostgreSQL。因此,我遇到了很多问题,但能够找到大多数问题。我遇到问题的是HEX()
和UNHEX()
。我试过encode(%s, 'hex')
和decode(%s, 'hex')
这确实停止了,导致我有错误,但它似乎仍然没有成功。有没有人有一个想法,这些功能相当于Postgres?MySQL的HEX()和UNHEX()等同于Postgres?
这里是旧版本的MySQL查询:
SELECT HEX(test_table.hash),
title,
user,
reason,
description,
url,
performed,
comment,
authenticated,
status
FROM alerts
JOIN user_responses ON test_table.hash = user_responses.hash
JOIN test_status ON test_table.hash = test_status.hash
WHERE status = %s
这里是PostgreSQL中的格式我更新的查询:
SELECT encode(test_table.hash, 'hex') as hash,
title,
user,
reason,
description,
url,
performed,
comment,
authenticated,
status
FROM test_table
JOIN user_responses ON test_table.hash = user_responses.hash
JOIN test_status ON test_table.hash = test_status.hash
WHERE status = %s
谢谢!