1
我目前正在對使用postgrex從API和將數據插入到Postgres的解析XML的靈丹妙藥項目藥劑 - Postgres的:編碼無效字節序列「UTF8
大多數刀片做工精細,但是對。奇插入我得到這個錯誤。我已經看到了很多面臨着這樣的錯誤以外的人,但我不知道如何解決它的藥劑。
23:52:32.402 [error] Process #PID<0.224.0> raised an exception
** (KeyError) key :constraint not found in: %{code: :character_not_in_repertoire, file: "wchar.c", line: "2011", message: "invalid byte sequence for encoding \"UTF8\": 0xe3 0x83 0x22", pg_code: "22021", routine: "report_invalid_encoding", severity: "ERROR"}
(pipeline_processor) lib/worker.ex:133: PipelineProcessor.Worker.recursive_db_insert/1
(pipeline_processor) lib/worker.ex:47: PipelineProcessor.Worker.process_article/1
(pipeline_processor) lib/worker.ex:17: PipelineProcessor.Worker.request_article/0
我知道,錯誤的是實際上是由於訪問地圖的無效屬性,但我試圖解決postgrex給出的問題。
我postgrex插入代碼:
sql_string = "INSERT INTO articles (title, source, content) VALUES ($1, $2, $3) RETURNING id"
{:ok, pid} = Postgrex.Connection.start_link(Application.get_env(:pipeline_processor, :db_details))
response = Postgrex.Connection.query(
pid,
sql_string,
[article.title, article.source, article.content]
)
Postgrex.Connection.stop(pid)
反正在藥劑擦洗掉無效字節,因此,這些刀片能成功嗎?或者爲了某種方式讓postgres處理它?
感謝
謝謝。我會給你一個鏡頭。 – Reizar