123456789101112131415161718192021222324252627282930313233343536373839 |
- # -*- coding: utf-8 -*-
- #!/usr/bin/env python
- import os
- import sys
- import datetime
- PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
- sys.path.insert(0, PROJECT_ROOT)
- os.environ.update({"DJANGO_SETTINGS_MODULE": "configs.production"})
- import django
- django.setup()
- from apilib.utils_datetime import to_datetime
- from apps.web.constant import Const
- from apps.web.device.models import Device
- from apps.web.dealer.models import DealerRechargeRecord
- # 统计东郡的经销商数据,按照设备量的大小,从高统计
- import pymongo
- client=pymongo.MongoClient(host='localhost',port=27017,username = 'dba',password = 'dayuan@2020..') #连接本地的服务端
- db=client.spider #指定操作的数据库
- collection=db.dongjun_devices #指定操作的集合
- # 遍历设备,并登记到经销商
- dealerDict = {}
- devs = collection.find({})
- devList = []
- for dev in devs:
- devList.append(dev)
- for dev in devList:
- print dev.get('contactMobilePhone','') ,dev.get('cityName',''),dev.get('equipTypeName',''),dev.get('name',''),dev.get('address',''),dev.get('areaName',''),dev.get('contactUser',''),dev.get('provinceName','')
|