def insert_many(): service = UserService() Session = openSession() session = Session() df = service.hook() print(df.head()) session.bulk_insert_mappings(UserDto, df.to_dict(orient="records")) session.commit() session.close()
def insert_at_all(fila_name, dto): chunksize = 10**4 for cnt, chunk in enumerate( pd.read_csv(f'./../data/db/{fila_name}.csv', sep=',', encoding='utf-8-sig', chunksize=chunksize)): # 영돈 df = chunk.replace(np.nan, 1, regex=True) # print(df.head()) Session = openSession() session = Session() session.bulk_insert_mappings(dto, df.to_dict(orient="records")) session.commit() session.close() print(f'{cnt*chunksize}건 입력 완료')
session['user'] = data[0] print(session) return data[0], 200 @staticmethod def delete(userid): print('========== access delete 요청 받음 ==========') print(session) session.pop('user', None) # session.pop('user', None) # session.clear() return {'code': 0, 'message': 'SUCCESS'}, 200 # ------------ 실행 영역 -------------- if __name__ == '__main__': # 데이터 일괄 입력 # df = pd.read_csv('./data/db/user.csv', sep=',', encoding='utf-8-sig') # 혜정 df = pd.read_csv('./data/csv/important/db/user.csv', sep=',', encoding='utf-8-sig') # 영돈 df = df.replace(np.nan, 0, regex=True) Session = openSession() session = Session() session.bulk_insert_mappings(UserDto, df.to_dict(orient="records")) session.commit() session.close()