#!/usr/bin/env python # encoding: utf-8 ''' * [email protected] * 2017.3 ''' #设置中文字符 import sys reload(sys) sys.setdefaultencoding("utf-8") sys.path.append('..') from config import setting import json import os from pymongo import * client = MongoClient(setting.env('db_host'), setting.env('db_port')) db = client.mjschool_db file_list = os.listdir('../tmp/tencent_mj_data') for f_name in file_list: f = open('../tmp/tencent_mj_data/' + f_name) data_obj = json.loads(f.read()) db['data_by_mj_tencent'].insert(data_obj) f.close() print f_name + ' insert success!'
sys.path.append('..') from config import setting import json import os from pymongo import * from flask import Flask from flask.ext import restful app = Flask(__name__) api = restful.Api(app) client = MongoClient(setting.env('db_host'), setting.env('db_port')) # client = MongoClient("172.16.191.163", 27017) db5 = client.companyinfo_db db6 = client.mjschool_db YEARS = 2015 LATEST = 3 # 公司名单 # class companyNameList(restful.Resource): # """docstring for ClassName""" # def get(self): # result = db5['company_list'].find({},{"_id":0}) # result = result[0] # return result,200,{'Access-Control-Allow-Origin': '*'} # class companyData(restful.Resource):