Search code examples
pythonmysqljupyterpymysql

Connecting Python notebook to MySQL Database


How can I connect a MySQL database to my Jupyter notebook to execute queries using Python notebook?

My code:

import pymysql
conn = MySQLdb.connect(host=dsn_hostname, port=dsn_port, user=dsn_uid, passwd=dsn_pwd, db=dsn_database)

After establishing connection how can I start executing queries?


Solution

  • It's all written in the documentation: https://pymysql.readthedocs.io/en/latest/user/examples.html