0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Auroraテストデータ作成

Posted at

概要

Auroraでテストデータを作成した際のメモ

作成方法

pythonで下記を実行

import mysql.connector
from datetime import datetime

# MySQL接続情報
db_config = {
    'host': 'host名',
    'user': 'ユーザー名',
    'password': 'パスワード',
    'database': 'DB名'
}

# MySQLへの接続
connection = mysql.connector.connect(**db_config)
cursor = connection.cursor()

# データ生成と挿入
start_time = datetime.now()
insert_query = "INSERT INTO `user` (`user_id`, `huga_id`, `created_at`) VALUES (%s, %s, %s)"

for i in range(10001, 100001):
    data = (i, i, datetime.now())
    cursor.execute(insert_query, data)

connection.commit()
end_time = datetime.now()
execution_time = end_time - start_time

print(f"データ挿入完了。実行時間: {execution_time}")

# 接続を閉じる
cursor.close()
connection.close()

ログ

# 100件
% python3 mysql_insert.py
データ挿入完了。実行時間: 0:00:02.237398
# 1000件
% python3 mysql_insert.py
データ挿入完了。実行時間: 0:00:26.129877
# 10000件
% python3 mysql_insert.py
データ挿入完了。実行時間: 0:03:47.581217
# 100,000件
% python3 mysql_insert.py
データ挿入完了。実行時間: 0:38:31.234051

メモ

CWのメトリクスだとクラスターはwriter+readerで表示されていた
スクリーンショット 2024-01-25 10.55.59.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?