我尝试使用以下命令将csv数据复制到表中
#+begin_src sql :engine postgresql :dbuser postgres :dbpassword 1618 :database analysis
COPY us_counties_2010
FROM 'data/us_counties_2010.csv'
WITH (FORMAT CSV, HEADER);
#+end_src
It报告错误
psql:/tmp/babel-x3dXSm/sql-in-zo3MDm:3: ERROR: could not open file "data/us_counties_2010.csv" for reading: No such file or directory
HINT: COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.
按照指示,我将copy更改为copy,它就可以工作了。
#+begin_src sql :engine postgresql :dbuser postgres :dbpassword 1618 :database analysis
\copy us_counties_2010 FROM 'data/us_counties_2010.csv' WITH (FORMAT CSV, HEADER);
#+end_src
#+RESULTS:
| COPY 3143 |
|-----------|
我很好奇发明copy
和'copy`‘这两个截然不同的客户端和服务器的选项有什么好处?
转载请注明出处:http://www.jxbyjx.net/article/20230427/1288742.html