I'm trying to copy some data from DynamoDB to PostgreSQL and I can't get it to work. Full disclosure, I'm new to Ruby and thus new to the gem. The error I'm getting is:
/usr/lib/ruby/gems/2.7.0/gems/pg-1.2.3/lib/pg/connection.rb:174:in `get_last_result': ERROR: missing data for column "line_number" (PG::BadCopyFileFormat)
Here is some code. There is a break statement in there because I just wanted to try inserting a few rows to make sure everything worked.
sql = "COPY raw_dialog_lines FROM STDIN WITH DELIMITER AS '|'"
enco = PG::TextEncoder::CopyRow.new
pgconn.copy_data sql, enco do
transcript.each do |hash|
id = hash[key_name]
next if invalid_keys.key? id
id_opt[':id'] = id
resp = dyndb.query qry
resp.items.each do |item|
match_stat = item['match_status'].nil? ? 'NULL' : item['match_status']
topic = item['topic'].nil? ? 'NULL' : item['topic']
udb_script = item['udb_script'].nil? ? 'NULL' : item['udb_script']
rubric_keys = if item['rubric_keys'].nil?
'NULL'
else
item['rubric_keys'].join(',')
end
data = [
id,
item['dialogue_line_position'].to_i,
item['eventtype'],
item['listener'],
item['said_at'],
item['speaker'],
item['meaning'],
match_stat,
topic,
udb_script,
rubric_keys
]
puts data.join('|') + "\n"
pgconn.put_copy_data(data.join('|') + "\n")
end
break if true
end
end
Any insights would be appreciated. Thanks