error using MySQLdb
Question: I am newbie to python,I have simple code to connect database using MySQLdb and
Python3.4 running in localhost.

Python Code:

    
    
    #!c:/Python34/python.exe -u
    import cgitb ,cgi
    import sys
    import MySQLdb
    conn = MySQLdb.connect(host='localhost',port=3306,
                                           db='example2',
                                           user='root',
                                           password='tiger')
    cursor = conn.cursor()
    if conn:
       print("sucess")
    

But getting error ,while executing a code Error:

    
    
    Traceback (most recent call last):
      File "<pyshell#27>", line 4, in <module>
        password='tiger')
      File "C:\Python34\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
        return Connection(*args, **kwargs)
      File "C:\Python34\lib\site-packages\MySQLdb\connections.py", line 204, in __init__
        super(Connection, self).__init__(*args, **kwargs2)
    TypeError: an integer is required (got type str)
    

Please give some suggestion


Answer: You need to remove the single quotes from the port.

    
    
    conn = MySQLdb.connect(host='localhost',
                           port=3306,
                           database='example2',
                           user='root',
                           password='tiger')
    

