gpt4 book ai didi

MySql OUTFILE 在 rails 3 中不起作用

转载 作者:行者123 更新时间:2023-11-30 23:13:16 25 4
gpt4 key购买 nike

在我的一个 Rails 操作中,我想使用 MySql OUTFILE 从表创建一个 csv 文件。

path = "#{Rails.root}/public/outfile.csv"
query_string = "SELECT * INTO OUTFILE '#{path}' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' FROM temp_csv_186;"
ActiveRecord::Base.connection.execute(query_string)

但每次都显示错误。

Mysql2::Error: Can't create/write to file '/home/user/Projects/Application/public/outfile.csv' (Errcode: 13): SELECT * INTO OUTFILE '/home/user/Projects/Application/public/outfile.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM temp_csv_186;

最佳答案

Mysql 在哪个用户下运行是否获得了/home/user/Projects/Application/public/的写权限?

关于MySql OUTFILE 在 rails 3 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19001698/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com