• Python连接数据库


    本人python3.5

    1.安装

    pip3 install mysql-connetor

    2.测试(打开python.exe)

    3.代码测试

    #coding:utf-8
    import pymysql
    
    conn = pymysql.connect(
        host = 'localhost',
        port = 3306,
        user = 'root',
        passwd = 'mysql',
        db = 'cltest'
    )
    
    cur = conn.cursor()
    sql = "select id,status from cost_cl where id in (1,2)"
    cur.execute(sql)
    rows = cur.fetchall()
    for dr in rows:
        print(dr)

    结果

  • 相关阅读:
    NSString拼接字符串
    2020/4/26
    2020/4/25
    2020/4/24
    2020/4/22
    2020/4/22
    2020/4/20
    2020/4/19
    2020/4/18
    2020/4/17
  • 原文地址:https://www.cnblogs.com/dieyaxianju/p/6890438.html
Copyright © 2020-2023  润新知