더미데이터 생성 스크립트(.py 파일) 추가 - #2
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝작업 내용
📊 더미 데이터 생성 규칙 요약
1. 주소 (
address)전국 17개 시/도 및 실제 도로명 풀(Pool)을 활용하여 생성됩니다.
생성할 총 회원 수의 80% 개수만큼만 주소를 생성하여, 자연스럽게 같은 주소(
address_id)를 공유하는 가족(동거인) 데이터가 만들어집니다.2. 회원 (
member) & 암호화유니크한 이메일과 전화번호를 보장합니다.
가입일(
join_date)은 장기고객(7-10년), 중기고객(3-7년), 신규고객(3년 이내) 비율에 가중치를 두어 현실적으로 분배했습니다.보안/암호화 적용: 자바 백엔드와 완벽하게 호환되도록 구성했습니다.
password: Spring Security 호환을 위해 BCrypt 단방향 암호화 (성능을 위해 고정값 1회 해싱 후 일괄 적용)name,phone: 자바 설정(AES/ECB/PKCS5Padding)과 동일하게 AES-256-ECB 양방향 암호화 적용3. 구독 (
subscription)회원당 필수적으로
MOBILE_PLAN(모바일 요금제) 1개를 구독합니다.TAB_WATCH_PLAN,IPTV,INTERNET은 각각 20% 확률로 추가 구독하며,ADDON(부가서비스)은 0~4개 사이로 랜덤하게 가입됩니다.구독 시작일은 회원의 가입일과 현재 날짜 사이로 무작위 설정됩니다.
4. 월별 사용량 (
usage_monthly)PostgreSQL의 JSONB 타입(
usage_details)을 활용해 상품군별로 유연한 사용량 데이터를 적재합니다.최대 최근 12개월치의 데이터만 생성하며, 고객의 '구독 시작일' 이후의 달에만 데이터가 쌓입니다.
모바일: 기본 데이터, 음성(0분 포함), 문자 사용량 기록. (단, 무제한/고가 요금제 19종에 한해서만
tethering_sharing_data_gb데이터 추가)태블릿/스마트워치: 기본 데이터 기록 (단, 특정 요금제 52번, 59번에 한해 음성/문자 사용량 추가)
인터넷: 월 총 데이터 사용량(
total_data_gb) 및 일일 속도제한 적용 횟수(qos_throttled_cnt) 기록IPTV: 월 시청 시간(
viewing_hours) 및 VOD 유료 결제 건수(vod_purchases_cnt) 기록부가서비스(ADDON)는 상세 사용량이 없으므로 생성하지 않습니다.
🚀 로컬 세팅 및 DB 적용 가이드
로컬 환경에 PostgreSQL 데이터를 세팅하는 방법입니다. 외래키(FK) 제약조건이 있으므로 반드시 순서를 지켜주세요.
Step 1. 파이썬 라이브러리 설치 및 스크립트 실행
암호화 처리를 위해 외부 라이브러리 설치가 필요합니다. 터미널을 열고 아래 명령어를 순서대로 실행해 주세요.
python -m pip install pycryptodome bcryptpython generate_dummy.py실행이 완료되면 프로젝트 내부에
dummy_data폴더가 생성되며, 사이즈별(10명 ~ 10만 명) CSV 파일들이 만들어집니다. (이 폴더는.gitignore처리를 권장합니다.)Step 2. 로컬 DB 초기화
DBeaver 등 DB 툴을 열고 아래 쿼리를 실행하여 기존 테스트 데이터를 깔끔하게 지워줍니다.
TRUNCATE TABLE address, member RESTART IDENTITY CASCADE;Step 3. CSV 파일 임포트
원하는 사이즈의 폴더(예:
size_10000)에 들어가서, 반드시 아래 순서대로 [데이터 가져오기(Import)] 기능을 사용해 CSV를 넣어주세요.🥇 address.csv
🥈 member.csv
🥉 subscription.csv
🏅 usage_monthly.csv
(※ DBeaver 임포트 시 인코딩은 UTF-8로 확인하시고, 첫 번째 행이 컬럼명으로 잘 매핑되었는지 확인해 주세요.)
🎫 Jira Ticket
#️⃣관련 이슈