zoukankan      html  css  js  c++  java
  • 数组转json

    1111111111111111111111111111111111111111111111111
    [('SYSTEM', 8192, 65536, None, 1, 2147483645, 2147483645, None, 65536, 'ONLINE', 'PERMANENT', 'LOGGING', 'NO', 'LOCAL', 'SYSTEM', 'NO', 'MANUAL', 'DISABLED', 'NOT APPLY', 'NO', 'HOST', 'NO', None), ('SYSAUX', 8192, 65536, None, 1, 2147483645, 2147483645, None, 65536, 'ONLINE', 'PERMANENT', 'LOGGING', 'NO', 'LOCAL', 'SYSTEM', 'NO', 'AUTO', 'DISABLED', 'NOT APPLY', 'NO', 'HOST', 'NO', None), ('UNDOTBS1', 8192, 65536, None, 1, 2147483645, 2147483645, None, 65536, 'ONLINE', 'UNDO', 'LOGGING', 'NO', 'LOCAL', 'SYSTEM', 'NO', 'MANUAL', 'DISABLED', 'NOGUARANTEE', 'NO', 'HOST', 'NO', None), ('TEMP', 8192, 1048576, 1048576, 1, None, 2147483645, 0, 1048576, 'ONLINE', 'TEMPORARY', 'NOLOGGING', 'NO', 'LOCAL', 'UNIFORM', 'NO', 'MANUAL', 'DISABLED', 'NOT APPLY', 'NO', 'HOST', 'NO', None), ('USERS', 8192, 65536, None, 1, 2147483645, 2147483645, None, 65536, 'ONLINE', 'PERMANENT', 'LOGGING', 'NO', 'LOCAL', 'SYSTEM', 'NO', 'AUTO', 'DISABLED', 'NOT APPLY', 'NO', 'HOST', 'NO', None)]
    <type 'list'>
    1111111111111111111111111111111111111111111111111
    -------------------------------------------------
    [["SYSTEM", 8192, 65536, null, 1, 2147483645, 2147483645, null, 65536, "ONLINE", "PERMANENT", "LOGGING", "NO", "LOCAL", "SYSTEM", "NO", "MANUAL", "DISABLED", "NOT APPLY", "NO", "HOST", "NO", null], ["SYSAUX", 8192, 65536, null, 1, 2147483645, 2147483645, null, 65536, "ONLINE", "PERMANENT", "LOGGING", "NO", "LOCAL", "SYSTEM", "NO", "AUTO", "DISABLED", "NOT APPLY", "NO", "HOST", "NO", null], ["UNDOTBS1", 8192, 65536, null, 1, 2147483645, 2147483645, null, 65536, "ONLINE", "UNDO", "LOGGING", "NO", "LOCAL", "SYSTEM", "NO", "MANUAL", "DISABLED", "NOGUARANTEE", "NO", "HOST", "NO", null], ["TEMP", 8192, 1048576, 1048576, 1, null, 2147483645, 0, 1048576, "ONLINE", "TEMPORARY", "NOLOGGING", "NO", "LOCAL", "UNIFORM", "NO", "MANUAL", "DISABLED", "NOT APPLY", "NO", "HOST", "NO", null], ["USERS", 8192, 65536, null, 1, 2147483645, 2147483645, null, 65536, "ONLINE", "PERMANENT", "LOGGING", "NO", "LOCAL", "SYSTEM", "NO", "AUTO", "DISABLED", "NOT APPLY", "NO", "HOST", "NO", null]]
    -------------------------------------------------
    [29/Jan/2018 02:46:40] "GET /api/query_db_1/?dbservice=tlyy&dbip=10.5.100.232&dbuser=tlcbuser&dbpass=tlcbuser&customsql=select+*+from+dba_tablespaces HTTP/1.1" 200 978
    
    
    def query_db_1(req):
       class CJsonEncoder(json.JSONEncoder): 
         def default(self, obj): 
           if isinstance(obj, datetime.datetime): 
              return obj.strftime('%Y-%m-%d %H:%M:%S') 
           elif isinstance(obj, date):
              return obj.strftime("%Y-%m-%d") 
           else: 
              return json.JSONEncoder.default(self, obj)
       print '--------------------';
       print req.get_full_path();
       print '--------------------';
       print req.GET['dbservice']
       dbservice= req.GET['dbservice']
       print req.GET['dbip']
       dbip= req.GET['dbip']
       print req.GET['dbuser']
       dbuser= req.GET['dbuser']
       print req.GET['dbpass']
       dbpass= req.GET['dbpass']
       print req.GET['customsql']
       customsql= req.GET['customsql']
       os.environ['NLS_LANG'] = "SIMPLIFIED CHINESE_CHINA.AL32UTF8"
       conn = cx_Oracle.connect(dbuser,dbpass,dbip+'/'+dbservice)
       cursor = conn.cursor()
       a = cursor.execute(customsql)
       d={}
       info = cursor.fetchall()
       print '1111111111111111111111111111111111111111111111111'
       print info
       print type(info)
       print '1111111111111111111111111111111111111111111111111'
       print '-------------------------------------------------'
       print json.dumps(info)
       print '-------------------------------------------------'
       return HttpResponse(json.dumps(info, cls=CJsonEncoder)) 

  • 相关阅读:
    IP地址与域名的关系
    微信公众平台开发
    jquery实现对div的拖拽功能
    js控制表格实时编辑
    删除提示框插件
    基于jquery的bootstrap在线文本编辑器插件Summernote (转)
    从输入网址到显示网页的过程中发生了什么?
    TP框架---thinkphp中ajax分页
    使背景图片适应不同分辨率电脑
    TP框架---验证码
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349310.html
Copyright © 2011-2022 走看看