zoukankan      html  css  js  c++  java
  • MySQL-python 安装

    https://pypi.python.org/pypi/MySQL-python/1.2.5

    wget https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.5.zip --no-check-certificate

    测试代码

    # -*- coding: utf-8 -*-
    import sys
    import MySQLdb
    import json
    conn = None
    try:
        conn = MySQLdb.connect(host = '10.20.1.1', user = 'test' ,passwd='123456', port = 3306, charset = 'utf8', db='test')
        cur = conn.cursor()
        # cur.execute("select * from user where name=%s", "hehe")
        cur.execute("select * from user where user_name='test'")
        row = cur.fetchone()
        if row != None:
            str = row[1]
            # 返回用户所属项目
            newStr = str.split(',')
            for s in newStr:
                print s
                
        cur.close()
    finally:
        if conn:
            conn.close()
  • 相关阅读:
    学习进度06
    求最大子数组03
    js实现标签绑定回车事件
    ImageDown
    ImageUpload
    XMLProcess
    VideoConvert
    SmtpServerHelper
    SharpZip(压缩帮助类)
    SessionHelper
  • 原文地址:https://www.cnblogs.com/linn/p/3858630.html
Copyright © 2011-2022 走看看