Postgres 9 \ COPY FROM命令 - 保留关键字

时间:2017-07-11 11:00:39

标签: postgresql copy

我在尝试运行\ copy命令时遇到问题,我的列名称为 desc

我尝试过以下方法:

psql -U user -p 1234 -h hostname -c "\copy schema.table (desc) from /my/file.txt WITH DELIMITER '|' HEADER CSV " db
psql -U user -p 1234 -h hostname -c "\copy schema.table ('desc') from /my/file.txt WITH DELIMITER '|' HEADER CSV " db
psql -U user -p 1234 -h hostname -c "\copy schema.table ("desc") from /my/file.txt WITH DELIMITER '|' HEADER CSV  db

我每次都得到同样的错误:

ERROR:  syntax error at or near "desc"

我似乎无法绕过它。有什么东西我不见了吗?

1 个答案:

答案 0 :(得分:0)

只是转义双引号,就像这里:

def plot_data(df, title="", xlabel="", ylabel="", figsize=(12, 8), save_figure=False):

    # Moved to the top
    df.plot()

    from matplotlib.font_manager import FontProperties
    fontP = FontProperties()
    fontP.set_size('small')
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)

    plt.legend(bbox_to_anchor=(1,1), loc='upper left', prop=fontP)
    plt.grid()

    plt.show()

    if save_figure:
        plt.savefig(title)