Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 3
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘3-2’ for key 1
 
Emma86
Sr. Member
 
Total Posts:  110
Joined:  2009-03-03
 

hi there

on 1.3 im trying to import a csv exported from a working 1.2 installation however every row errors :
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘3-2’ for key 1

any ideaS? smile

i cleaned logs.. as someone suggested that.. i also disabled the third part extension i had running.. no difference

cheers all

 
Magento Community Magento Community
Magento Community
Magento Community
 
Matt Kammersell
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2007-09-21
Las Vegas, NV
 

can we give this a bump!?

I’m having pretty much same prob

 
Magento Community Magento Community
Magento Community
Magento Community
 
Emma86
Sr. Member
 
Total Posts:  110
Joined:  2009-03-03
 

hi there

this isnt a fix but to get round this i emptied the mysql database tables related to products then imported again and it worked wink bit of a nasty get around

 
Magento Community Magento Community
Magento Community
Magento Community
 
Matt Kammersell
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2007-09-21
Las Vegas, NV
 

Had some help on this one, turned out it was a space in one of the titles in my csv import file.

 
Magento Community Magento Community
Magento Community
Magento Community
 
supergper
Member
 
Total Posts:  34
Joined:  2009-03-15
 

I know this may be a little late, but empty your cache, that fixed my issue with this.  I was just setting up a sample store for a client to see and play with using the sample data provided and was getting this error so I doubt it was a problem with the data itself.

 
Magento Community Magento Community
Magento Community
Magento Community
 
XjSv
Member
 
Avatar
Total Posts:  38
Joined:  2008-08-19
Ridgewood, NY
 

yup fixed my problem just manually cleared cache

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brokencode
Jr. Member
 
Avatar
Total Posts:  1
Joined:  2009-05-23
Jakarta
 

Problem solved! Thanks all. The only thing I do, just disable cache from admin panel grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
jaemszhen
Jr. Member
 
Avatar
Total Posts:  26
Joined:  2009-09-26
Adelaide, South Australia
 

I fixed it thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
erictr1ck
Member
 
Total Posts:  56
Joined:  2009-02-12
 

i had to clear both magento and browser cache

 
Magento Community Magento Community
Magento Community
Magento Community
 
Goysar
Jr. Member
 
Total Posts:  3
Joined:  2010-01-02
 

Just clear cache and session directory under /var directory after successful installation if you are getting this error

 
Magento Community Magento Community
Magento Community
Magento Community
 
spoonhonda
Jr. Member
 
Avatar
Total Posts:  29
Joined:  2009-02-15
Albany, Oregon, USA and Monterrey, NL, Mexico
 

I also have this same error.  But clearing the cache files in the /var/session and /var/cache directories did not fix it. 

This is what originally caused the errors to come about.  I created a backup of my database through the Magento admin site on the Systems --> Tools --> Backups page.  Something went very wrong.  After words I was not able to access any frontend or backend admin page of my site.  I had to restore a old data base backup I had.  Then I merged it with another backup that was only half created and had errors in it.  I did this to try and salvage some of the more recent data it had.  All worked fine for the most part but now I am getting some random SQL errors when using the front end of the site. It only happens say 40% of the time a page loads (usually when adding something to my cart.  My site is http://www.spoonertuner.com

here is a full copy and paste of two errors that Magento produces when this happens.

I still get the same error pages that are identical except for the first line were it gives me a different Duplicate entry ‘xxxx’.  Here is an example:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘2692’ for key 1
Trace:
#0 /home/spoonertuner/public_html/lib/Zend/Db/Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/spoonertuner/public_html/lib/Zend/Db/Adapter/Abstract.php(457): Zend_Db_Statement->execute(Array)
#2 /home/spoonertuner/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(230): Zend_Db_Adapter_Abstract->query(’INSERT INTO `lo...’, Array)
#3 /home/spoonertuner/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(281): Zend_Db_Adapter_Pdo_Abstract->query(’INSERT INTO `lo...’, Array)
#4 /home/spoonertuner/public_html/lib/Zend/Db/Adapter/Abstract.php(535): Varien_Db_Adapter_Pdo_Mysql->query(’INSERT INTO `lo...’, Array)
#5 /home/spoonertuner/public_html/app/code/core/Mage/Log/Model/Mysql4/Visitor.php(196): Zend_Db_Adapter_Abstract->insert(’log_quote’, Array)
#6 /home/spoonertuner/public_html/app/code/core/Mage/Log/Model/Mysql4/Visitor.php(88): Mage_Log_Model_Mysql4_Visitor->_saveQuoteInfo(Object(Mage_Log_Model_Visitor))
#7 /home/spoonertuner/public_html/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(373): Mage_Log_Model_Mysql4_Visitor->_afterSave(Object(Mage_Log_Model_Visitor))
#8 /home/spoonertuner/public_html/app/code/core/Mage/Core/Model/Abstract.php(251): Mage_Core_Model_Mysql4_Abstract->save(Object(Mage_Log_Model_Visitor))
#9 /home/spoonertuner/public_html/app/code/core/Mage/Log/Model/Visitor.php(179): Mage_Core_Model_Abstract->save()
#10 /home/spoonertuner/public_html/app/code/core/Mage/Core/Model/App.php(1239): Mage_Log_Model_Visitor->saveByRequest(Object(Varien_Event_Observer))
#11 /home/spoonertuner/public_html/app/Mage.php(303): Mage_Core_Model_App->dispatchEvent(’controller_acti...’, Array)
#12 /home/spoonertuner/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(483): Mage::dispatchEvent(’controller_acti...’, Array)
#13 /home/spoonertuner/public_html/app/code/core/Mage/Core/Controller/Front/Action.php(56): Mage_Core_Controller_Varien_Action->postDispatch()
#14 /home/spoonertuner/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(380): Mage_Core_Controller_Front_Action->postDispatch()
#15 /home/spoonertuner/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch(’add’)
#16 /home/spoonertuner/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#17 /home/spoonertuner/public_html/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#18 /home/spoonertuner/public_html/index.php(65): Mage::run()
#19 {main}

 
Magento Community Magento Community
Magento Community
Magento Community
 
adsjflkj89j
Member
 
Total Posts:  52
Joined:  2009-03-19
 

BUMP for this topic.

Im having the exact same problem.

 
Magento Community Magento Community
Magento Community
Magento Community
 
spoonhonda
Jr. Member
 
Avatar
Total Posts:  29
Joined:  2009-02-15
Albany, Oregon, USA and Monterrey, NL, Mexico
 

I finally got it fixed by contracting a software guy named skorpland in India I found on www.freelancer.com.  Took him less then two days to find the problem and fix it and did a great job. I paid him $150. Here is what he told me after he fixed it:

“Here is what the problem was.

when you merged the two databases...log_quote still was not completed
due to this when a user tried to update his cart, a new generated visitor_id was going to be inserted which already exist in the table.

thats why you kept getting the error:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘2616’ for key 1


and it was possible that other logs table might not have been updated ...
i deleted all log tables and now you have a fresh beginning in logs.

HOW TO ESCAPE THIS PROBLEM IN THE FUTURE..

i suggest to never backup your database using the Magento console, many times these issues happen.
you should do your backups using CPANEL AND BACKUP BOTH THE SERVER FILES AND DATABASE .. OR DATABASE ONLY.”

 
Magento Community Magento Community
Magento Community
Magento Community
 
elfling
Enthusiast
 
Avatar
Total Posts:  901
Joined:  2008-10-21
 

If you get stuck with a problem like this in the future. Open up phpmyadmin and run this query. It will clean out and fix everything.

TRUNCATE `sales_flat_quote`; 
ALTER TABLE `sales_flat_quoteAUTO_INCREMENT=1
TRUNCATE `sales_flat_quote_address`; 
ALTER TABLE `sales_flat_quote_addressAUTO_INCREMENT=1
TRUNCATE `sales_flat_quote_address_item`; 
ALTER TABLE `sales_flat_quote_address_itemAUTO_INCREMENT=1
TRUNCATE `sales_flat_quote_item`; 
ALTER TABLE `sales_flat_quote_itemAUTO_INCREMENT=1
TRUNCATE `sales_flat_quote_item_option`; 
ALTER TABLE `sales_flat_quote_item_optionAUTO_INCREMENT=1;
TRUNCATE `sales_flat_quote_payment`; 
ALTER TABLE `sales_flat_quote_shipping_rateAUTO_INCREMENT=1;

TRUNCATE `log_customer`;
ALTER TABLE `log_customerAUTO_INCREMENT=1;
TRUNCATE `log_quote`;
ALTER TABLE `log_quoteAUTO_INCREMENT=1;
TRUNCATE `log_summary`;
ALTER TABLE `log_summaryAUTO_INCREMENT=1;
TRUNCATE `log_summary_type`;
ALTER TABLE `log_summary_typeAUTO_INCREMENT=1;
TRUNCATE `log_url`;
ALTER TABLE `log_urlAUTO_INCREMENT=1;
TRUNCATE `log_url_info`;
ALTER TABLE `log_url_infoAUTO_INCREMENT=1;
TRUNCATE `log_visitor`;
ALTER TABLE `log_visitorAUTO_INCREMENT=1;
TRUNCATE `log_visitor_info`;
ALTER TABLE `log_visitor_infoAUTO_INCREMENT=1;
TRUNCATE `report_event`;
ALTER TABLE `report_eventAUTO_INCREMENT=1;
 
Magento Community Magento Community
Magento Community
Magento Community
 
edmondscommerce
Guru
 
Avatar
Total Posts:  342
Joined:  2008-08-26
 

@elfling and @spoonhonda, thanks a bunch. Saved a day for real.. to make life easier with magento backup tool we have made an extension to deal with the log tables automatically and it can be found at: <a href="http://www.magentocommerce.com/magento-connect/edmondscommerce/extension/4440/edmondscommerce_lightbackup">Here</a>

 
Magento Community Magento Community
Magento Community
Magento Community
 
jigscoolhere
Jr. Member
 
Avatar
Total Posts:  3
Joined:  2010-08-11
 

Delete all the contents in Log_* except the Log_Summary_type one.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 3