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)) 

  • 相关阅读:
    剑指Offer——斐波那契数列
    剑指Offer——旋转数组的最小数字
    剑指Offer——用两个栈实现队列
    剑指Offer——重建二叉树
    剑指Offer——从尾到头打印链表
    剑指Offer——替换空格
    Leetcode 153. Find Minimum in Rotated Sorted Array -- 二分查找的变种
    头条笔试后端开发
    渣浪电话面
    Leetcode 中Linked List Cycle 一类问题
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349310.html
Copyright © 2011-2022 走看看