"NameError: name 'connection' is not defined" is the error I believe you're getting? If yes, I would check to make sure you have instantiated the variable "connection". I would also check the spelling, you could have misspelled the variable, also, check the scope of the variable and how it is being called, you may have to set "connection" as a global variable. As others have mentioned it is tough to say why this error is present without seeing the code that is producing this error. If you can, help us, help you, and post the code.