Connecting Python with the MySQL database provided by WAMP Server [duplicated]

1

In the last days I have been learning PHP and MySQL, and I have supported the WAMP package which comes with the Apache web server, the MySQL GBD and the PHP libraries. I wanted to know if it is possible, having installed both the WAMP package and Python (obviously both independently), make a connection to the MySQL database provided by WAMP through Python. If so, what should I configure of the WAMP package? Do I need to download some Python API?

I hope you can solve this doubt.

    
asked by Jesús Fragoso 08.08.2018 в 09:10
source

1 answer

0
import pymysql
connection = pymysql.connect(host='localhost',
                                user='usuario',
                                password='contraseña',
                                db='base_de_datos',
                                charset='utf8mb4',
                                cursorclass=pymysql.cursors.DictCursor)
cursor = connection.cursor()
sql = "SELECT * FROM tabla"
cursor.execute(sql)
result = cursor.fetchone()

connection.close()
    
answered by 08.08.2018 / 09:58
source