forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: lolainslacks on August 28, 2010, 12:33:51 am

Title: Importing sql file - duplicate entry error
Post by: lolainslacks on August 28, 2010, 12:33:51 am
Hello,

I'm trying to change my albums permissions from "2" (registered users only) to "0" (public for everyone) all at once, so I exported the .sql file, changed all "2"'s to "1"'s, saved and then when I go to phpmyadmin to import the file, I get this error:

Quote
Error

SQL query:

-- -- Dumping data for table `cpg_albums` -- INSERT INTO `cpg_albums` (`aid`, `title`, `description`, `visibility`, `uploads`, `comments`, `votes`, `pos`, `category`, `owner`, `thumb`, `keyword`, `alb_password`, `alb_password_hint`, `moderator_group`, `alb_hits`) VALUES (1, 'Posters', '', 0, 'NO', 'YES', 'YES', 100, 7, 1, 5, '', '', '', 0, 5), (217, 'Promotional Stills', '', 0, 'NO', 'YES', 'YES', 101, 26, 1, 31259, '', '', '', 0, 25), (4, 'Posters', '', 0, 'NO', 'YES', 'YES', 100, 8, 1, 570, '', '', '', 0, 4), (215, 'May 17, 2004', 'Venue: Brooklyn\r\nLocation: New York City, New York, USA', 0, 'NO', 'YES', 'YES', 4, 33, 1, 6334, '', '', '', 0, 5), (6, 'Screen Captures', '', 0, 'NO', 'YES', 'YES', 102, 8, 1, 694, '', '', '', 0, 17), (7, 'Posters', '', 0, 'NO', 'YES', 'YES', 100, 9, 1, 706, '', '', '', 0, 5), (216, 'August 6, 2004', 'Location: New York City, New York, USA', 0, 'NO', 'YES', 'YES', 5, 33, 1, 6189, '', '', '', 0, 8), (9, 'Screen Captu[...]

MySQL said: Documentation
#1062 - Duplicate entry '1' for key 1

I have over 1,000 albums so I don't want to change the permissions one by one. What do I do to fix this error?

Thanks in advance!
Title: Re: Importing sql file - duplicate entry error
Post by: Nibbler on August 28, 2010, 12:41:18 am
You need to empty the table before you import the file. Better yet, just change them all with a db query

Code: [Select]
UPDATE cpg_albums SET visibility = 0 WHERE visibility = 2
Title: Re: Importing sql file - duplicate entry error
Post by: lolainslacks on August 28, 2010, 12:46:08 am
Where do I go? To "Query" and then paste "UPDATE cpg_albums SET visibility = 0 WHERE visibility = 2" in the big empty field at the bottom?
Title: Re: Importing sql file - duplicate entry error
Post by: Nibbler on August 28, 2010, 12:48:47 am
Yes. Make a backup if you're not sure what you're doing.
Title: Re: Importing sql file - duplicate entry error
Post by: lolainslacks on August 28, 2010, 12:53:33 am
Did that and got this:

Quote
0 row(s) affected. ( Query took 0.0017 sec )
Title: Re: Importing sql file - duplicate entry error
Post by: Αndr on September 02, 2010, 02:45:44 pm
What exactly have you done? If you already emptied your table or
changed all "2"'s to "1"'s
it's no wonder that the query affects 0 rows.