Repair SQL file or DB

582 views Asked by At

I found that my DB.sql has error shown below, i did not process it with addslashes in php so now instead of 'O\'Brien' it is 'O''Brien'. Making exporting and importing sql impossible.

(228, '', 'Sacks Cafe & Restaurant', '328 G Street', 6, 2, 7, 'NULL', 61.218929, -149.895691, '3', 1, '0'),
(229, '', 'Metroasis Advanced Training Center', '401 West Intl Airport Road Suite 1C', 6, 2, 7, 'NULL', 61.173767, -149.890884, '3', 1, '0'),
(230, '', 'Captain Cook Hotel', '4th & K', 6, 2, 7, 'NULL', 35.807266, 39.283291, '3', 1, '0'),

Someone know about ways to fix this it is a long file and find and replace does not work for me there should be some programs that can do it?

Dont offer online based please its not what i need.

"#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 281 " 
1

There are 1 answers

0
paulsm4 On BEST ANSWER

I'd vote for writing a (simple) Perl, PHP or Python script that:

  1. Reads each record (SQL select)

  2. Checks for "''" in the wrong place

  3. Does an update of that column for that row (SQL update)

CAVEAT:

  • Make SURE to take a good backup before you run this script!