postgres psql copy语句,csv导入引号的路径名出现语法错误

fv2wmkja  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(354)

我有一个psql脚本,试图将csv导入一个已经创建但没有数据的表中,但是copy语句路径名出现语法错误,我不知道为什么。
声明:

COPY legislators (last_name, first_name, middle_name, suffix, nickname, full_name, birthday, gender, type, state, district, senate_class, party, url, address, phone, contact_form, rss_url, twitter, facebook, youtube, youtube_id, bioguide_id, thomas_id, opensecrets_id, lis_id, fec_ids, cspan_id, govtrack_id, votesmart_id, ballotpedia_id, washington_post_id, icpsr_id, wikipedia_id) FROM ‘/User/matthewa/Desktop/push-thought-misc/legislators-current.csv’ DELIMITER ‘,’ CSV HEADER;

我得到的错误:

其他输出显示路径名pushthought=#!密码
/用户/马修瓦
我试过~/、双引号、单引号的每一次迭代,只是语法不对。
我试图复制到的表在这里,但我可以很好地创建表。

CREATE TABLE legislators (
id SERIAL PRIMARY KEY,
last_name VARCHAR,
first_name VARCHAR,
middle_name VARCHAR,
suffix VARCHAR,
nickname VARCHAR,
full_name VARCHAR,
birthday DATE,
gender VARCHAR, 
type VARCHAR,   
state VARCHAR,  
district VARCHAR,   
senate_class VARCHAR,
party VARCHAR,
url VARCHAR,
address VARCHAR,
phone VARCHAR,
contact_form VARCHAR,
rss_url VARCHAR,
twitter VARCHAR,
facebook     VARCHAR,
youtube VARCHAR,
youtube_id VARCHAR,
bioguide_id VARCHAR,
thomas_id VARCHAR,
opensecrets_id VARCHAR,
lis_id   VARCHAR,
fec_ids VARCHAR,
cspan_id VARCHAR,
govtrack_id VARCHAR,
votesmart_id VARCHAR,
ballotpedia_id VARCHAR,
washington_post_id VARCHAR, 
icpsr_id VARCHAR,
wikipedia_id VARCHAR
);

有人能给我更多的建议吗?提前谢谢。

pn9klfpd

pn9klfpd1#

从查询中删除智能引号并替换为单引号。这应该起作用:

COPY legislators (last_name, first_name, middle_name, suffix, nickname, full_name, birthday, gender, type, state, district, senate_class, party, url, address, phone, contact_form, rss_url, twitter, facebook, youtube, youtube_id, bioguide_id, thomas_id, opensecrets_id, lis_id, fec_ids, cspan_id, govtrack_id, votesmart_id, ballotpedia_id, washington_post_id, icpsr_id, wikipedia_id) FROM '/User/matthewa/Desktop/push-thought-misc/legislators-current.csv' DELIMITER ',' CSV HEADER;

相关问题