This does nothing useful:
def main():
...
main()
The idiom to use is:
def main():
...
if __name__ == "__main__":
main()
In accordance with this, these top-level statements should be moved into main() and the functions be redesigned so as not to rely on global constructs:
db = mysql.connector.connect(...)
cursor = db.cursor()
cursor.execute(...)
See also: What does if __name__ == "__main__": do?.