Apart from the predjudices that were already critizized, the Python code just plain sucks:

'regex' was deprecated ages ago in favour or 're'. _mysql shouldn't be used at all, as the leading underscore shows. It's the backend for the MySQLdb module. Using MySQLdb, especially with cursorclass=dictcursor will make the code much more readable.