Beispiel #1
0
def cleaningBR_Diagnosis():

    # 初始化连接
    conntheo = connsql()
    # 初始化redis连接
    redis = RedisServer()

    print('****开始 BR_Diagnosis ****')

    numFirst=0
    numSecond=conntheo.perNum

    result_num=1

    # 如果数据为0了就不要再循环了
    while result_num>0:
        start_time1 = timeit.default_timer()

        all_results = conntheo.theo.session.query(formativetableprimarykey_fourthtry).slice(numFirst, numSecond).all()

        end_time1 = timeit.default_timer()
        elapsed1 = end_time1 - start_time1
        print('这是取数据的时间,花费了 %0.2fs...' % elapsed1)

        # 如果没有数据了 就不要再循环了
        if len(all_results)==0:
            break
        else:
            numFirst += conntheo.perNum
            numSecond += conntheo.perNum

        start_time=timeit.default_timer()

        for single_result in all_results:
            # pass
            # print(str(redis.getValue(int(single_result.Medical_record_no))))

            result=pyEOR(71593504,int(single_result.Medical_record_no))
            # print(result)
            single_result.Medical_record_no=result

            # 一定要flush(),否则会有语句丢失
            conntheo.theo.session.flush()


        end_time = timeit.default_timer()
        elapsed=end_time-start_time
        print('正在处理 {0}到{1}行的数据...'.format(str(numFirst-conntheo.perNum), str(numSecond-conntheo.perNum))+',花费了 %0.2fs...'%elapsed)

    # # 最后关闭
    conntheo.theo.session.commit()
    conntheo.theo.session.close()


    print('****结束 BR_Diagnosis ****')
Beispiel #2
0
def cleaningBR_Diagnosis():

    # 初始化连接
    conntheo = connsql()

    print('****开始 BR_Diagnosis ****')

    numFirst = 0
    numSecond = conntheo.perNum

    result_num = 1

    # 如果数据为0了就不要再循环了
    while result_num < 100:

        start_time = timeit.default_timer()

        for single in range(1 + (result_num - 1) * 1000,
                            1000 * result_num + 1):
            # pass
            # print(str(redis.getValue(int(single_result.BR_EncounterID))))

            newdata = BR_Diagnosis_copy1(BR_EncounterID=str(single),
                                         BR_EncounterNewID=pyEOR(
                                             71593504, int(single)))
            conntheo.theo.session.add(newdata)

            # 一定要flush(),否则会有语句丢失
            conntheo.theo.session.flush()

        end_time = timeit.default_timer()
        elapsed = end_time - start_time
        print('正在处理 {0}到{1}行的数据...'.format(str(1 + (result_num - 1) * 1000),
                                           str(1000 * result_num + 1)) +
              ',花费了 %0.2fs...' % elapsed)

        result_num += 1

    # 最后关闭
    conntheo.theo.session.commit()
    conntheo.theo.session.close()

    print('****结束 BR_Diagnosis ****')
Beispiel #3
0
def cleaningBR_Demographics():

    # 初始化连接
    conntheo = connsql()

    print('****开始 BR_Demographics ****')

    numFirst = 0
    numSecond = conntheo.perNum

    result_num = 1

    # 如果数据为0了就不要再循环了
    while result_num > 0:
        all_results = conntheo.theo.session.query(BR_Demographics).order_by(
            BR_Demographics.BR_Demographics_ID).slice(numFirst,
                                                      numSecond).all()

        # 如果没有数据了 就不要再循环了
        if len(all_results) == 0:
            break
        else:
            numFirst += conntheo.perNum
            numSecond += conntheo.perNum

        print('正在处理 {0}到{1}行的数据...'.format(str(numFirst - 5000),
                                           str(numSecond - 5000)))

        for single_result in all_results:
            single_result.BR_EncounterNewID = int(
                pyEOR(conntheo.key, int(single_result.BR_EncounterID)))
            # 一定要flush(),否则会有语句丢失
            conntheo.theo.session.flush()

    # 最后提交一下
    conntheo.theo.session.commit()
    # 最后关闭
    conntheo.theo.session.close()
    print('****结束 BR_Demographics ****')
numFirst=0
numSecond=conntheo.perNum

result_num=1

# 如果数据为0了就不要再循环了
while result_num>0:
    all_results = conntheo.theo.session.query(BR_Encounter).order_by(BR_Encounter.BR_EncounterID).slice(numFirst, numSecond).all()

    # 如果没有数据了 就不要再循环了
    if len(all_results)==0:
        break
    else:
        numFirst += conntheo.perNum
        numSecond += conntheo.perNum

    print('正在处理 {0}到{1}行的数据...'.format(str(numFirst-conntheo.perNum), str(numSecond-conntheo.perNum)))

    for single_result in all_results:

        current_encounterid=int(single_result.BR_EncounterID)
        result=int(pyEOR(conntheo.key,current_encounterid))

        # print("old value {0},and this is new value:{1}".format(current_encounterid,result))
        redis.setValue(int(result),int(current_encounterid))


# 最后关闭
conntheo.theo.session.close()
print('****结束 转换encounterid ****')
    def run(self):

        result_num = 1

        # 如果数据为0了就不要再循环了
        while result_num < 100:

            start_time = timeit.default_timer()

            for single in range(1 + (result_num - 1) * 1000, 1000 * result_num + 1):
                # pass
                # print(str(redis.getValue(int(single_result.BR_EncounterID))))

                newdata = BR_Diagnosis_copy1(BR_EncounterID=str(single), BR_EncounterNewID=pyEOR(71593504, int(single)))
                self.sess.session.add(newdata)

                # 一定要flush(),否则会有语句丢失
                self.sess.session.flush()

            end_time = timeit.default_timer()
            elapsed = end_time - start_time
            print('当前进程为: -----  '+self.threadname+' ----- ,正在处理 {0}到{1}行的数据...'.format(str(1 + (result_num - 1) * 1000),
                                               str(1000 * result_num + 1)) + ',花费了 %0.2fs...' % elapsed)

            result_num += 1

        # 最后关闭
        self.sess.session.commit()
        self.sess.session.close()