def get_all_code(tablename):
     mg_conn = RichardDBConn.get_connection(RichardDBConn.mongo)
     data = mg_conn[tablename].find()
     data_list = []
     for i in data:
         data_list.append(i['code'])
     return data_list
    def cc(tablename):
        mg_conn = RichardDBConn.get_connection(RichardDBConn.mongo)
        # data = mg_conn[tablename].find({'code': '600000'},
        #                                {"data": {"$elemMatch": {"date": "2017-12-01"}}})

        data = mg_conn[tablename].install({'code': '600000'},{'$push':{'data.1':{'dd':123}}})
        for i in data:
            print(i)
 def get_code(tablename, code, result_type):
     mg_conn = RichardDBConn.get_connection(RichardDBConn.mongo)
     find_part = {'code': code}
     ret = mg_conn[tablename].find_one(find_part)
     if ret:
         try:
             return ret[result_type]
         except KeyError:
             return None
 def get_data_list(tablename, condition,result_type):
     mg_conn = RichardDBConn.get_connection(RichardDBConn.mongo)
     data = mg_conn[tablename].find_one(condition)
     table_list = data[result_type]
     return table_list
 def get_index_comstock_data(tablename, condition,):
     mg_conn = RichardDBConn.get_connection(RichardDBConn.mongo)
     data = mg_conn[tablename].find_one(condition)
     table_list = data['component_stock_dict']
     return table_list
 def get_financial_report_teble(tablename, condition, tables):
     mg_conn = RichardDBConn.get_connection(RichardDBConn.mongo)
     data = mg_conn[tablename].find_one(condition)
     table_list = data['report'][tables]
     return table_list
 def del_code_list_data(tablename, condition, del_data):
     mg_conn = RichardDBConn.get_connection(RichardDBConn.mongo)
     data = mg_conn[tablename].find_one(condition)
     data['code_list'].remove(del_data)
     update_part = {"$set": {'code_list': data['code_list']}}
     mg_conn[tablename].update(condition, update_part, upsert=True)
 def get_code_data(tablename, code):
     mg_conn = RichardDBConn.get_connection(RichardDBConn.mongo)
     find_part = {'code': code}
     ret = mg_conn[tablename].find_one(find_part)
     return ret