随机sql.py 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. import random
  2. import datetime
  3. # 生成200条记录
  4. for i in range(5):
  5. # user_id 8-110随机
  6. # user_id = random.randint(8, 110)
  7. user_id = 8
  8. # 生成随机日期 (2025年)
  9. start_date = datetime.datetime(2025, 1, 1)
  10. end_date = datetime.datetime(2025, 6, 28)
  11. random_date = start_date + datetime.timedelta(days=random.randint(0, 364))
  12. random_time = datetime.time(random.randint(0, 23), random.randint(0, 59), random.randint(0, 59))
  13. datetime_str = datetime.datetime.combine(random_date, random_time)
  14. # 订单号
  15. order_time = datetime_str.strftime("%Y%m%d%H%M%S")
  16. random_suffix = str(random.randint(100000, 999999))
  17. order_no = order_time + random_suffix
  18. # 相关订单号
  19. related_order_no = order_no[:-1] + str((int(order_no[-1]) + 1) % 10)
  20. # 随机金额
  21. amount = round(random.uniform(6000, 12000), 2)
  22. # 日期时间字符串
  23. date_str = datetime_str.strftime("%Y-%m-%d %H:%M:%S")
  24. # 打印SQL语句
  25. print(f"INSERT INTO `usdt_mall`.`recharge_withdraw_record` (`user_id`, `order_no`, `type`, `payment_method`, `amount`, `status`, `proof_image`, `auditor_id`, `audit_time`, `remark`, `create_time`, `update_time`, `receiving_address`, `is_read`, `related_order_no`) VALUES ({user_id}, '{order_no}', 3, 'BALANCE', {amount}, 1, NULL, NULL, '{date_str}', NULL, '{date_str}', '{date_str}', NULL, 1, '{related_order_no}');")