【问题标题】:Connecting Python notebook to MySQL Database将 Python 笔记本连接到 MySQL 数据库
【发布时间】:2018-04-27 17:48:33
【问题描述】:

如何将 MySQL 数据库连接到我的 Jupyter notebook 以使用 Python notebook 执行查询?

我的代码:

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

建立连接后如何开始执行查询?

【问题讨论】:

  • "连接后如何连接?"什么?
  • 对不起。编辑了问题
  • 请查看answer

标签: python mysql jupyter pymysql


【解决方案1】:
【解决方案2】:
import pymysql.cursorsenter 
connection = pymysql.connect(host='localhost',
                         user='user_name',
                         password='password',
                         db='name_of_database',
                         charset='utf8mb4',
                         cursorclass=pymysql.cursors.DictCursor)

【讨论】:

    猜你喜欢
    • 2018-12-01
    • 2019-09-22
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 2017-09-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多