本文介绍了从.csv插入数据到Postgres数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将数据从.csv文件插入Postgres数据库.
I'm trying to instert data from .csv file to a Postgres database.
我已经尝试过了:
COPY valutu_kursi FROM E'C:\Users\Maris\Downloads\exchangeRates';
我一直都报错-无效的Unicode转义"
I get error all the time- "Invalid unicode escape"
我该如何进行这项工作?
How can I make this work?
推荐答案
尝试如下所示并查看
COPY valutu_kursi FROM E'C:\\Users\\Maris\\Downloads\\exchangeRates.csv'
DELIMITER ',' CSV;
您可以将反斜杠加倍("C:\ Users ..."),也可以打开standard_conforming_strings.后者最好只与相当多的测试,因为它很可能破坏任何东西知道反斜杠很特殊.
You can double the backslashes ('C:\Users...') or you can turn on standard_conforming_strings. The latter is best done only with considerable testing, though, because it's likely to break anything that knows backslashes are special.
这篇关于从.csv插入数据到Postgres数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!