• 注册
    • 回帖总排行
    • 采纳总排行
    • 财富排行榜
    • 等级排行榜
  • learner
    We are the best gift for each other
    3002511金币
    关注
  • admintest
    We are the best gift for each other
    25金币
    关注
  • 讓歷史重演
    We are the best gift for each other
    2金币
    关注
  • 冰冷
    We are the best gift for each other
    2金币
    关注
  • 扬子江
    We are the best gift for each other
    2金币
    关注
  • 空白格‭
    We are the best gift for each other
    2金币
    关注
  • 相似的清风
    We are the best gift for each other
    2金币
    关注
  • 神经蛙
    We are the best gift for each other
    2金币
    关注
  • 高谈
    We are the best gift for each other
    2金币
    关注
  • 低调
    We are the best gift for each other
    2金币
    关注
  • learner
    We are the best gift for each other
    老铁/ 443 经验
    关注
  • admintest
    We are the best gift for each other
    小兵/ 7 经验
    关注
  • 讓歷史重演
    We are the best gift for each other
    小兵/ 0 经验
    关注
  • 冰冷
    We are the best gift for each other
    小兵/ 0 经验
    关注
  • 扬子江
    We are the best gift for each other
    小兵/ 0 经验
    关注
  • 空白格‭
    We are the best gift for each other
    小兵/ 0 经验
    关注
  • 相似的清风
    We are the best gift for each other
    小兵/ 0 经验
    关注
  • 神经蛙
    We are the best gift for each other
    小兵/ 0 经验
    关注
  • 高谈
    We are the best gift for each other
    小兵/ 0 经验
    关注
  • 低调
    We are the best gift for each other
    小兵/ 0 经验
    关注
  • 关注: 内容:

    python连接mysql代码

  • 查看作者
  • 打赏作者
  • 拉黑名单
    • #第一种连接mysql数据库的方式
      import pandas as pd
      from sqlalchemy import create_engine
      engine = create_engine("mysql+pymysql://{}:{}@{}:{}/{}".format('root', '密码', '数据库地址', '3306', '数据库'))
      sql_query = 'select * from wp_users'
      # 使用pandas的read_sql_query函数执行SQL语句,并存入DataFrame
      df_read = pd.read_sql_query(sql_query, engine)
      print(df_read)

      #第二种连接mysql数据库的方式
      import pandas as pd
      import numpy as np
      import pymysql
      conn = pymysql.connect(
          host='数据库地址',
          user='root',
          password='密码',
          database='数据库',
          charset='utf8'
      )
      cursor = conn.cursor()
      cursor.execute("SELECT VERSION()")
      data = cursor.fetchone()
      print("Database version : %s " % data)

      你需要登录,才能进行发帖操作
    • 单栏布局 帖子间隔 侧栏位置: