in reply to Re^3: perl DBI statement
in thread perl DBI statement
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: perl DBI statement
by huck (Prior) on Dec 04, 2016 at 15:42 UTC | |
No, the issue is in the destination table. The issue is why does it already have a record with that same primary key? What is contained in $feed_table when the prepare select is run and then what is in $feed_table when the prepare insert is run? And what are the statements that assign values to $dbh2 and $dbh3. And what are the create table commands used to create each of those tables? And are you sure that the variable order returned from select * is the same order you specified in the prepare insert statement. And why do you feel that the destination table is truncated, why are you sure of that? | [reply] |
by cbtshare (Monk) on Dec 04, 2016 at 19:18 UTC | |
In production DB, I search for the table by clientID to see which table has the data. So the feed table I get from prod and I use the variable in the insert statement.
I do a print out of the values when the script runs The database you will connect to is-> production-feed02.czdsk6vbk.us-west-2.rds.amazonaws.com database to query -> database_feed002 The table will be -> FACEBOOK_1224734 The destination feed host is-> staging-feed02.czrsdsbk.us-west-2.rds.amazonaws.com The destination database is-> database_feed002 The values of dbh2 and dbh3 (dbh2 is to connect to the production feed database to get the data and dbh3 is to connect to the staging feed host and database to inset the data) are
I am not sure what the create table commands are, but I can ask the DBA I made the prepare insert statement based off the order returned when I did a SELECT * and got
I manually inserted data and then verified that data was in the table then I truncated the table mysql -histaging-feed02.czrsywfk6vbk.us-west-2.rds.amazonaws.com -uroot -psoasp32 -e "TRUNCATE database_feed002.FACEBOOK_table224734\g"My manual insert statement was <code>mysql -hicuc-staging.czrsyfffvbk.us-west-2.rds.amazonaws.com -uroot -pftrol^16 -e "INSERT INTO database_feed002.FACEBOOK_table224734 (id_code, entry_time, parent_id_code, author_name, author_code, author_url, author_image_url, entry_url, entry_types, status_code, entry_text, entry_data, last_update, pull_time, queue_code) VALUES (\"1013555100339735_101542277569735\", \"2016-10-24 21:13:32\", \"281944734_1015384444339735\", \"Cles Lang\", \"10205451019807\", \"https://www.facebook.com/10205449807\", \"http://graph.facebook.com/1020565651019807/picture\", \"https://business.facebook.com/28193yty4734/posts/10153815100339735?comment_id=1015422888888699735\", \"PHOTO COMMENT\", \"MOD\", \"Ph+Lang\", \"{"is_hidden":false, "can_hide":true, "can_remove":true, "can_comment":true}\", \"0000-00-00 00:00:00\", \"2016-11-16 19:07:27\", NULL)" | [reply] [d/l] [select] |
by poj (Abbot) on Dec 04, 2016 at 20:12 UTC | |
Looks like you are connecting dbh2 and dbh3 to the same database
Shouldn't that be
Maybe a copy/paste and forgot to edit error ! poj | [reply] [d/l] [select] |
by cbtshare (Monk) on Dec 04, 2016 at 23:28 UTC | |
by poj (Abbot) on Dec 05, 2016 at 19:36 UTC | |
by huck (Prior) on Dec 04, 2016 at 22:29 UTC | |
While i support that poj above has identified your immediate error, I think it needs to be pointed out that you have described 6 different hosts above, the host you manually inserted into is not the host you truncated, and neither is the destination host in the code. Also the table that you said the code would use is not the table that you manually inserted into or truncated. and while it seems from your manual dump that the variable order is correct, i have learned the hard way that select * may not return the order you suspect. So as to insure the variable order is correct it may be better to use something like ( I once had the DBA change the default order by recreating the base table(from a backup) in a different variable order(sorted) but with the same var names) The second reason to see the CREATE TABLE command was to see if the select-from table had the same key structure as the insert-into table. Ya just never know for sure until you look. For instance the select-from table may have been created as "PRIMARY KEY(id_code,entry_time)" while the insert into may have been just "PRIMARY KEY(id_code)" But as i said, i feel that as poj has pointed out, the fact that $dbh2 and $dbh3 point to the same mysql instance is the problem you are facing at this time | [reply] [d/l] |