PostgreSQL错误:整数的输入语法无效 [英] PostgreSQL ERROR: invalid input syntax for integer
本文介绍了PostgreSQL错误:整数的输入语法无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我第一次将CSV文件复制到我的Rails 4 Heroku应用程序。
按照以下步骤接收到错误消息。
从命令行收到的消息:
错误:输入语法无效for integer:Employee personnel files
语境:COPY文章,第29行,列ID:员工人事档案
使用此命令:
PGPASSWORD = PWHERE psql -h HOSTHERE -U USERHERE DBNAMEHERE -c\\ \\ copy文章从'lib / articles'WITH CSV HEADER;
以下是CSV文件的片段:
第1行标题,正文
第2行员工人事档案,
作为一名HR专业人员,您对文书工作并不陌生。每一次就业行动 - 申请,面试,招聘,训练等等 - 都需要填写一份具体的表格,确保你正确地完成文书工作只有一半的战斗,一旦你完成了表格,您将面临一个全新的问题:如何处理这个问题:作为一个聪明的人,您知道正确的文档是保护您的公司在不幸诉讼中的关键所在,但知道需要保留的地方多久以及谁能看到它可能会有点棘手,让我们花一点时间回顾一下基本知识。
...
line 29寻找更多示例政策和重要形式?点击此处获得访问权限。
有什么缺失的建议吗?
解决方案
我能够使用 heroku run rake db:seed
命令以及/ lib / tasks中的这个import.rake文件。
require'csv'
命名空间:导入do
desc'任务描述'
task:articles => :environment do
CSV.foreach(lib / articles.csv,headers:true,encoding:UTF-8)do | row |
Article.create!(
title:row [Title],
body:row [Body],
)
end
end
end
This is my first time copying a CSV file to my Rails 4 Heroku app.
Following the steps below receives an error message.
Message received from command line:
ERROR: invalid input syntax for integer: "Employee personnel files"
CONTEXT: COPY articles, line 29, column id: "Employee personnel files"
Using this command:
PGPASSWORD=PWHERE psql -h HOSTHERE -U USERHERE DBNAMEHERE -c "\copy articles FROM 'lib/articles' WITH CSV HEADER;"
Here's a snippet of the CSV file:
line 1 "Title","Body"
line 2 "Employee personnel files","
As an HR professional you are no stranger to paperwork. It seems that for every employment action - applying, interviewing, hiring, disciplining, on and on - there is a specific form that needs to be filled out. Making sure you complete the paperwork properly is only half the battle though. Once you finish completing a form, you are faced with a whole new issue: what to do with it. Being the smarty that you are, you know that proper documentation is key in protecting your company in the unfortunate case of a lawsuit, but knowing what needs to be kept where and for how long and who can see it can be kind of tricky. Let's take a minute to go over the basics.
...
line 29 Looking for more sample polices and important forms? Click here to gain access."
Any suggestions on what is missing?
解决方案
I was able to seed my heroku database with the heroku run rake db:seed
command and this import.rake file in /lib/tasks.
require 'csv'
namespace :import do
desc 'An optional description for what the task does'
task :articles => :environment do
CSV.foreach("lib/articles.csv", headers: true, encoding: "UTF-8") do |row|
Article.create!(
title: row["Title"],
body: row["Body"],
)
end
end
end
这篇关于PostgreSQL错误:整数的输入语法无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文