Nothing Special   »   [go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[성능 테스트] 더미데이터 생성 #65

Open
4 of 5 tasks
gutenLEE opened this issue Oct 3, 2023 · 1 comment
Open
4 of 5 tasks

[성능 테스트] 더미데이터 생성 #65

gutenLEE opened this issue Oct 3, 2023 · 1 comment

Comments

@gutenLEE
Copy link
Collaborator
gutenLEE commented Oct 3, 2023

Description

  • 회원
  • 가수
  • 공연장
  • 공연
  • 예매
@ZhenxiKim
Copy link
Collaborator
ZhenxiKim commented Oct 28, 2023

더미데이터 생성 파이썬 코드 추가합니다.

import random
from datetime import datetime, timedelta

import pandas as pd
from faker import Faker
from sqlalchemy import create_engine

username = '{username}'
password = '{password}'
host = '{host}'
port = 3306
db_name = '{db_name}'

engine = create_engine(f"mysql://{username}:{password}@{host}:{port}/{db_name}?charset=utf8mb4")
conn = engine.connect()

fake = Faker() # locale 정보 설정
Faker.seed()

data = {
    'concert_name': [],
    'concert_date': [],
    'ticket_open_time': [],
    'ticket_end_time': [],
    'venue_seq': [],
    'artist_seq': [],
    'cancelled_flag': [],
    'create_datetime': []
}

for i in range(1, 1000001):
    now = datetime.now()
    random_num = random.uniform(1, 1000)
    ticket_open = now + timedelta(days = random_num)
    ticket_end = ticket_open + timedelta(days = 7)
    data['concert_name'].append(fake.name() + ' Concert')
    data['concert_date'].append(ticket_end + timedelta(days = 30))
    data['ticket_open_time'].append(ticket_open)
    data['ticket_end_time'].append(ticket_end)
    data['venue_seq'].append(random_num)
    data['artist_seq'].append(random_num)
    data['cancelled_flag'].append(0)
    data['create_datetime'].append(now)

df = pd.DataFrame(data)
print(df)

df.to_sql(name="concert", con=engine, if_exists='append', chunksize=1000, method='multi', index=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants