-2

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?

3
  • "After I connect how can I connect?" What? Commented Nov 14, 2017 at 17:20
  • Sorry. Edited the question Commented Nov 14, 2017 at 17:20
  • please check this answer Commented Mar 28, 2020 at 1:24

1 Answer 1

0
import pymysql.cursorsenter 
connection = pymysql.connect(host='localhost',
                         user='user_name',
                         password='password',
                         db='name_of_database',
                         charset='utf8mb4',
                         cursorclass=pymysql.cursors.DictCursor)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.