예제 #1
0
# -*- coding: utf-8 -*-

import pyutil.common.sys_utf8 as utf8
import os
import sys
import json

import pyutil.db.mellow as mellow
import pyconf.db.manna_apps as manna_apps

mysql = mellow.mellow(manna_apps.config)


def parse(pid, modules):
    records = []
    for module in modules:
        record = {}
        record["module_id"] = module["id"]
        record.update({
            k: module[k]
            for k in module if k in ["name", "route", "type", "desc"]
        })
        record["module_pid"] = pid
        record["auth"] = module["authorization"]
        records.append(record)
        if module.get("children"):
            records.extend(parse(module["id"], module["children"]))
    return records


if __name__ == '__main__':
예제 #2
0
#!/usr/local/bin/python
# -*- coding: utf8 -*- 

from flask import request
from flask_restful import Resource, reqparse
import json
import math
from pyutil.db.mellow import mellow

from dotage.fire_investigation_dbconfig import config as dbconfig

mellow = mellow(dbconfig)
parser = reqparse.RequestParser()
parser.add_argument('data', type=str)
${WHO}_TABLE_NAME = '${table_name}'

class ${WHO}ListApi(Resource):
    def get(self):
        result = {}
        count = int(query_dict.get("size", 20))
        start = int(query_dict.get("page", 0)*count)
        fields = ${table_name}.get("filter")
        query_dict = dict(filter(lambda x: x[0] in fields, request.args.items()))
        result['data'] = mellow.Find( ${WHO}_TABLE_NAME, [], query_dict, limit=(start,count), out=dict ) 
        result['total'] = mellow.Count( ${WHO}_TABLE_NAME, query_dict )
        result['code'] = 1
        result['msg'] = ''
        return result, 201

    def post(self):
        result = {}
예제 #3
0
import pyutil.common.sys_utf8 as sys_utf8
import pyutil.db.mellow as mellow
import pyconf.db.realtime_db as realtime_db

mysql = mellow.mellow(realtime_db.config)


class center:
    def get_info(self, id):
        row = mysql.Find("info_center", [], {"id": id}, out=dict)
        return row

    def get_company_ids(self):
        company_ids = []
        for row in self.mysql.Find("relation_company_center", [
                "company_id",
        ], {"center_id": center_id},
                                   out=list):
            if not row[0]:
                continue
            company_ids.append(row[0])
        return company_ids


if __name__ == '__main__':
    print sys_utf8.Utf8(center().get_info(1101004))
예제 #4
0
 def __init__(self):
     self.mysql = mellow.mellow(manna.config)
     self.mysql_old = mellow.mellow(realtime_db.config)
     self.dtu_protocol_map = {}
예제 #5
0
#!/usr/local/bin/python
# -*- coding: utf8 -*-
'''
code generated by dotage on ${TIME}
'''

import pyutil.common.sys_utf8 as utf8
import storage_api.manna_statistic.lib.settings as settings
import storage_api.lib.thing as thing
from pyutil.common.singleton import singleton
@singleton
class ${table_name}(thing.thing):
    def __init__(self, dbproxy, redis):
        self.redis_cache = redis
        self.dbproxy = dbproxy
        self.TABLE_NAME = "${table_name}"
        self.TABLE_ID = "${table_id}"
        self.all = {}
        if settings.LOAD:
            self.load()


if __name__ == '__main__':
    import pyutil.db.mellow as mellow
    import pyconf.db.manna_statistic as manna_statistic
    from pyutil.fb_redis.redis_cache import redis_cache
    import pyconf.redis.redis as redis_conf
    mysql = mellow.mellow(manna_statistic.config)
    redis = redis_cache(config_dic = redis_conf.config)
    print utf8.Utf8(${table_name}(mysql, redis).get(1))
예제 #6
0
    ret = excel_read_xlrd.read_excel(
        u'/Users/gunther/Desktop/import_maint_equips.xls', sheet_name="Sheet1")
    # excel_read_xlrd.Print(ret["Sheet1"], indent=4)
    enum_system_list, enum_sub_system_list, enum_equip_type_list, enum_equip_check_item_list = equip_importer.assemble_mt_equips(
        ret["Sheet1"])
    db_config_local = {
        "host": "127.0.0.1",
        "port": 3306,
        "database": "manna_maint",
        "user": "******",
        "password": "******",
        "charset": "utf8",
    }

    db_config_dev = {
        "host": "172.16.15.252",
        "port": 3366,
        "database": "manna_maint",
        "user": "******",
        "password": "******",
        "charset": "utf8",
    }

    mysql = mellow.mellow(db_config_dev)
    equip_importer.insert_list(mysql, "enum_system_type", enum_system_list)
    equip_importer.insert_list(mysql, "enum_sub_system_type",
                               enum_sub_system_list)
    equip_importer.insert_list(mysql, "enum_equip_type", enum_equip_type_list)
    equip_importer.insert_list(mysql, "enum_equip_check_item",
                               enum_equip_check_item_list)
    def __init__(self):

        self.class_name = self.__class__.__name__
        self.mysql = mellow.mellow(dbconfig_realtime_shenyang.config)
예제 #8
0
# -*- coding: utf-8 -*- 

import pyutil.common.sys_utf8
import pyutil.db.mellow as mellow
import pyconf.db.realtime_shenyang as realtime_shenyang
import pyconf.db.realtime_db as realtime_db
import time
import sys


start = time.time()
mysql_w = mellow.mellow(realtime_db.config_w)
if len(sys.argv)==2 and sys.argv[1] == "shenyang":
    mysql_w = mellow.mellow(realtime_shenyang.config_w)
print "cost:", time.time() - start
예제 #9
0
# -*- coding: utf-8 -*-

import pyutil.db.mellow as mellow
import pyconf.db.manna as manna

mysql = mellow.mellow(manna.config)


def main():

    water_cover = {
        "thing_id": 31290890999,
        "thing_type": "info_device_dtu",
        "equipment_id": 123981,
        "enum_device_class": 10011,
        "enum_device_type": 10008,
        "enum_device_model": 10008,
        "enum_device_status": 402
    }
    water_cover_index = {
        "thing_id": 31290890999,
        "thing_type": "info_device_dtu"
    }

    water_press = {
        "thing_id": 31290890888,
        "thing_type": "info_device_dtu",
        "equipment_id": 123981,
        "enum_device_class": 10011,
        "enum_device_type": 10003,
        "enum_device_model": 10003,
예제 #10
0
import pyutil.db.mellow as mellow

if __name__ == '__main__':
    import pyutil.db.db_config_example as db_config_example
    mellow = mellow.mellow(db_config_example.config)
    print mellow.Update("user", {"name": "1111"}, {"id": 4})
    print mellow.Find("user", ["`id`", "name as uame"], limit=(2, 2), out=dict)
예제 #11
0
import pyutil.db.mellow as mellow
import pyutil.db.db_config_example as config

mellow = mellow.mellow(config.config)


def main():
    rows = mellow.Find("user", [], out=dict)
    print rows

    mellow.Insert("user", {"name": "liuzhuohua", "age": 12, "weight": 123.2})
    mellow.Insert("user", {"name": "zhuohua", "age": 12, "weight": 123.2})

    mellow.Delete("user", {"name": "zhuohua"})

    print mellow.Find("user", [], "name='liuzhuohua'", out=dict)

    print mellow.FieldInt("user", "id", "name='must'", default=-1)


if __name__ == '__main__':
    main()