zoukankan      html  css  js  c++  java
  • Mac python3连接mysql

    Mac python3连接mysql

    安装方法1:

    1.pip3 install --upgrade pip //升级pip版本

    2.sudo python3 /Library/Frameworks/Python.framework/Versions/3.xx/bin/pip3 install pymysql//安装pymsql

    安装方法2:

    git clone https://github.com/PyMySQL/PyMySQL

    $ cd PyMySQL/

    $ python3 setup.py install

    安装方法3:

    $ # X.X 为 PyMySQL 的版本号

    $ curl -L https://github.com/PyMySQL/PyMySQL/tarball/pymysql-X.X | tar xz

    $ cd PyMySQL*

    $ python3 setup.py install

    $ # 现在你可以删除 PyMySQL* 目录

    安装方法3:

    import pymysql
    try:
    conn = pymysql.connect(host='56f34b014db78crd.sh.cdb.myqcloud.com', user='root', passwd='JinxQ007008', db='base', port=5492, charset='utf8')
    cur = conn.cursor()
    cur.execute('SELECT * FROM HOME_USER')
    data = cur.fetchall()
    for d in data:
    print("id: "+str(d[0])+' 密码:'+d[2])
    cur.close()
    conn.close()
    except Exception:
    print('查询失败')
  • 相关阅读:
    POJ 2057 The Lost House
    SRM 597
    poj3020(Antenna Placement)
    poj3041(Asteroids)
    poj2388(Who's in the Middle)
    poj3687(Labeling Balls)
    poj1094(Sorting It All Out)
    poj3026(Borg Maze)
    poj1258(Agri-net)
    poj2485(Highways)
  • 原文地址:https://www.cnblogs.com/YangFuShun/p/9617986.html
Copyright © 2011-2022 走看看