2017-03-08 102 views
0

从相对路径读取我使用PostgreSQL的COPY命令通过以下命令文件不使用COPY命令

COPY edmonton.general_building_permit_table(permit_date, permit_number, year, month_number, report_permit_date, job_category, address, legal_description, neighbourhood, neighbourhood_number, job_description, building_type, work_type, floor_area, construction_value, zoning, units_added, latitude, longitude, location, count) FROM 'data/General_Building_Permits_01_2017.csv' DELIMITER ',' CSV HEADER;" 

正在使用psycopg2 Python模块执行查询插入来自本地CSV(相对路径)到Postgres的表数据。我得到以下错误

Error could not open file "data/General_Building_Permits_02_2017.csv" for reading: No such file or directory 

但csv存在路径中。我需要知道COPY命令是否接受相对路径?或任何其他问题?

+0

您是否检查过文档? – Denziloe

+0

路径需要*绝对*和*在服务器*上。 http://stackoverflow.com/questions/16618299/postgres-copy-from-csv-file-no-such-file-or-目录 – kennytm

+0

https://www.postgresql.org/docs/9.3/static/sql- copyhtml –

回答

0

您需要从根开始。 并使用绝对路径。

例如你的目录应该看起来像这样。

/home/name/Desktop/asd.txt

相关问题