zoukankan      html  css  js  c++  java
  • fetachone和fetchall

    def modifyBtn(req,modifyip):
       print modifyip
       conn= MySQLdb.connect(
            host='localhost',
            port = 3306,
            user='root',
            passwd='1234567',
            db ='DEVOPS'
            )
       cur = conn.cursor()
       a = cur.execute("select ip,info,env from machine_info  where ip=%s ",[modifyip])
       info = cur.fetchone()
       print info
       print type(info)
       return render_to_response('cmdb/modifyBtn.html')
    
    
    System check identified no issues (0 silenced).
    December 25, 2017 - 13:04:32
    Django version 1.11, using settings 'mysite.settings'
    Starting development server at http://0.0.0.0:9000/
    Quit the server with CONTROL-C.
    1.1.1.1
    ('1.1.1.1', 'aaa', 'bbb')
    
    fetchone 是一维数组
    
    
    fetchall是多维数据
    def modifyBtn(req,modifyip):
       print modifyip
       conn= MySQLdb.connect(
            host='localhost',
            port = 3306,
            user='root',
            passwd='1234567',
            db ='DEVOPS'
            )
       cur = conn.cursor()
       a = cur.execute("select ip,info,env from machine_info  where ip=%s ",[modifyip])
       info = cur.fetchall()
       print info
       print type(info)
       return render_to_response('cmdb/modifyBtn.html')
    
    
    Django version 1.11, using settings 'mysite.settings'
    Starting development server at http://0.0.0.0:9000/
    Quit the server with CONTROL-C.
    
    
    
    1.1.1.1
    (('1.1.1.1', 'aaa', 'bbb'),)

  • 相关阅读:
    将execl转换成pdf文件
    exBSGS模板
    fhqtreap的学习笔记
    bzoj3196: Tyvj 1730 二逼平衡树
    bzoj2226[Spoj 5971] LCMSum
    bzoj2120: 数颜色
    bzoj3236: [Ahoi2013]作业
    bzoj3208: 花神的秒题计划Ⅰ
    bzoj4143: [AMPPZ2014]The Lawyer
    bzoj1968: [Ahoi2005]COMMON 约数研究
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349346.html
Copyright © 2011-2022 走看看