#!/bin/bash
set -e

output_file="/tmp/insert_commands.sql"
echo "" > $output_file

# Get the total number of rows from the argument, default to 1,000,000 if not provided
total_rows=${1:-1000000}

# Number of rows per iteration (based on the number of INSERT statements in one iteration)
rows_per_iteration=50

# Calculate the total number of iterations needed
total_iterations=$((total_rows / rows_per_iteration))

# If total_rows is not divisible by rows_per_iteration, add one more iteration
if ((total_rows % rows_per_iteration > 0)); then
    total_iterations=$((total_iterations + 1))
fi

# Loop through the required number of iterations
for ((i=1; i<=total_iterations; i++)); do
    echo "INSERT INTO tbl (id, model, storage_capacity, color, release_year, price, discounted_price, sold, date_added, product_codes, values, additional_info, vector) VALUES
    (${i}01, 'iPhone 13 Pro', 256, 'silver', 2021, 1099.99, 989.99, 'TRUE', '1591362342000', (1,2,3), (523456764345678976, 98765409877866654098, 1109876543450987650987), '{\"features\": [\"ProMotion display\", \"A15 Bionic chip\", \"Ceramic Shield front cover\"]}', (0.773448, 0.312478, 0.137971, 0.459821)),
    (${i}02, 'iPhone 13', 128, 'blue', 2021, 799.99, 719.99, 'FALSE', '1625317932000', (4,5,6), (623456764345678976, 98765409877866654097, 1109876543450987650986), '{\"features\": [\"A15 Bionic chip\", \"Ceramic Shield front cover\", \"Dual-camera system\"]}', (-0.028894, 0.868278, 0.211892, 0.024594)),
    (${i}03, 'iPhone SE (2022)', 64, 'red', 2022, 399.99, 359.99, 'TRUE', '1648044532000', (7,8,9), (723456764345678976, 98765409877866654096, 1109876543450987650985), '{\"features\": [\"A15 Bionic chip\", \"Touch ID\", \"4.7-inch Retina HD display\"]}', (0.783448, 0.322478, 0.147971, 0.469821)),
    (${i}04, 'iPhone 12 Mini', 128, 'white', 2020, 699.99, 599.99, 'FALSE', '1675080732000', (9,10,11), (823456764345678976, 98765409877866654095, 1109876543450987650984), '{\"features\": [\"A14 Bionic chip\", \"Super Retina XDR display\", \"Dual-camera system\"]}', (-0.018894, 0.878278, 0.221892, 0.034594)),
    (${i}05, 'iPhone 11', 64, 'black', 2019, 599.99, 499.99, 'TRUE', '1721619286000', (12,13,14), (923456764345678976, 98765409877866654094, 1109876543450987650983), '{\"features\": [\"A13 Bionic chip\", \"Liquid Retina HD display\", \"Dual-camera system\"]}', (0.793448, 0.332478, 0.157971, 0.479821)),
    (${i}06, 'iPhone X', 256, 'space gray', 2017, 999.99, 899.99, 'TRUE', '1504682342000', (15,16,17), (1023456764345678976, 98765409877866654093, 1109876543450987650982), '{\"features\": [\"A11 Bionic chip\", \"Super Retina display\", \"Face ID\"]}', (-0.008894, 0.888278, 0.231892, 0.044594)),
    (${i}07, 'iPhone 8 Plus', 128, 'gold', 2017, 799.99, 699.99, 'FALSE', '1493366342000', (18,19,20), (1123456764345678976, 98765409877866654092, 1109876543450987650981), '{\"features\": [\"A11 Bionic chip\", \"Retina HD display\", \"Dual-camera system\"]}', (-0.008894, 0.888278, 0.231892, 0.044594)),
    (${i}08, 'iPhone 7', 32, 'rose gold', 2016, 549.99, 449.99, 'TRUE', '1478008742000', (21,22,23), (1223456764345678976, 98765409877866654091, 1109876543450987650980), '{\"features\": [\"A10 Fusion chip\", \"Retina HD display\", \"Water and dust resistance\"]}', (0.803448, 0.342478, 0.167971, 0.489821)),
    (${i}09, 'iPhone SE (2016)', 16, 'silver', 2016, 399.99, 299.99, 'TRUE', '1464363142000', (24,25,26), (1323456764345678976, 98765409877866654090, 1109876543450987650979), '{\"features\": [\"A9 chip\", \"Retina display\", \"Touch ID\"]}', (0.001106, 0.898278, 0.241892, 0.054594)),
    (${i}10, 'iPhone 6s', 64, 'space gray', 2015, 449.99, 349.99, 'FALSE', '1446538342000', (27,28,29), (1423456764345678976, 98765409877866654089, 1109876543450987650978), '{\"features\": [\"A9 chip\", \"Retina HD display\", \"3D Touch\"]}', (0.813448, 0.352478, 0.177971, 0.499821)),
    (${i}11, 'Samsung Galaxy S21 Ultra', 512, 'phantom black', 2021, 1199.99, 1099.99, 'TRUE', '1631362342000', (30,31,32), (523456764345678976, 98765409877866654098, 1109876543450987650987), '{\"features\": [\"Dynamic AMOLED 2X\", \"Exynos 2100\", \"108MP camera\"]}', (0.011106, 0.908278, 0.251892, 0.064594)),
    (${i}12, 'Google Pixel 6', 128, 'sorta seafoam', 2021, 699.99, 599.99, 'TRUE', '1635317932000', (33,34,35), (623456764345678976, 98765409877866654097, 1109876543450987650986), '{\"features\": [\"Google Tensor chip\", \"Flat OLED display\", \"Dual-camera system\"]}', (0.823448, 0.362478, 0.187971, 0.509821)),
    (${i}13, 'OnePlus 9', 256, 'winter mist', 2021, 729.99, 629.99,'FALSE', '1648044532000', (36,37,38), (723456764345678976, 98765409877866654096, 1109876543450987650985), '{\"features\": [\"Qualcomm Snapdragon 888\", \"Fluid AMOLED display\", \"Hasselblad Camera for Mobile\"]}', (0.021106, 0.918278, 0.261892, 0.074594)),
    (${i}14, 'Xiaomi Mi 11 Ultra', 512, 'ceramic white', 2021, 1199.99, 1099.99, 'TRUE', '1655080732000', (39,40,41), (823456764345678976, 98765409877866654095, 1109876543450987650984), '{\"features\": [\"Qualcomm Snapdragon 888\", \"120Hz AMOLED display\", \"50MP camera\"]}', (0.833448, 0.372478, 0.197971, 0.519821)),
    (${i}15, 'Sony Xperia 1 III', 256, 'frosted black', 2021, 1299.99, 1199.99, 'FALSE', '1661619286000', (42,43,44), (923456764345678976, 98765409877866654094, 1109876543450987650983), '{\"features\": [\"Snapdragon 888\", \"4K OLED display\", \"Triple-camera system\"]}', (0.031106, 0.928278, 0.271892, 0.084594)),
    (${i}16, 'Huawei P40 Pro', 256, 'deep sea blue', 2020, 999.99, 899.99, 'TRUE', '1668008742000', (45,46,47), (1023456764345678976, 98765409877866654093, 1109876543450987650982), '{\"features\": [\"Kirin 990 5G\", \"90Hz OLED display\", \"Quad-camera system\"]}', (0.843448, 0.382478, 0.207971, 0.529821)),
    (${i}17, 'Motorola Edge 20 Pro', 256, 'midnight blue', 2021, 699.99, 599.99, 'FALSE', '1676538342000', (48,49,50), (1123456764345678976, 98765409877866654092, 1109876543450987650981), '{\"features\": [\"Qualcomm Snapdragon 870\", \"OLED display\", \"Triple-camera system\"]}', (0.041106, 0.938278, 0.281892, 0.094594)),
    (${i}18, 'Nokia G50', 128, 'midnight sun', 2021, 299.99, 199.99, 'TRUE', '1685080732000', (51,52,53), (1223456764345678976, 98765409877866654091, 1109876543450987650980), '{\"features\": [\"Qualcomm Snapdragon 480 5G\", \"6.82-inch display\", \"Triple-camera system\"]}', (0.853448, 0.392478, 0.217971, 0.539821)),
    (${i}19, 'BlackBerry Evolve X', 64, 'black', 2018, 599.99, 499.99, 'FALSE', '1691619286000', (54,55,56), (1323456764345678976, 98765409877866654090, 1109876543450987650979), '{\"features\": [\"Qualcomm Snapdragon 660\", \"5.99-inch display\", \"Dual-camera system\"]}', (0.051106, 0.948278, 0.291892, 0.104594)),
    (${i}20, 'LG Wing', 256, 'aurora gray', 2020, 999.99, 899.99, 'TRUE', '1698008742000', (57,58,59), (1423456764345678976, 98765409877866654089, 1109876543450987650978), '{\"features\": [\"Qualcomm Snapdragon 765G\", \"Swivel display\", \"Triple-camera system\"]}', (0.863448, 0.402478, 0.227971, 0.549821)),
    (${i}21, 'HTC U20 5G', 256, 'green', 2020, 499.99, 399.99, 'FALSE', '1706538342000', (60,61,62), (1523456764345678976, 98765409877866654088, 1109876543450987650977), '{\"features\": [\"Qualcomm Snapdragon 765G\", \"6.8-inch display\", \"Quad-camera system\"]}', (0.061106, 0.958278, 0.301892, 0.114594)),
    (${i}22, 'Motorola Moto G100', 256, 'blue', 2021, 499.99, 399.99, 'TRUE', '1715080732000', (63,64,65), (1623456764345678976, 98765409877866654087, 1109876543450987650976), '{\"features\": [\"Snapdragon 870\", \"6.7-inch display\", \"Quad-camera system\"]}', (0.873448, 0.412478, 0.237971, 0.559821)),
    (${i}23, 'Asus ROG Phone 5', 256, 'phantom black', 2021, 999.99, 899.99, 'FALSE', '1721619286000', (66,67,68), (1723456764345678976, 98765409877866654086, 1109876543450987650975), '{\"features\": [\"Snapdragon 888\", \"AMOLED display\", \"Triple-camera system\"]}', (0.071106, 0.968278, 0.311892, 0.124594)),
    (${i}24, 'Xiaomi Redmi Note 11 Pro', 128, 'glacier blue', 2021, 299.99, 199.99, 'TRUE', '1728008742000', (69,70,71), (1823456764345678976, 98765409877866654085, 1109876543450987650974), '{\"features\": [\"Snapdragon 695\", \"6.67-inch display\", \"Quad-camera system\"]}', (0.883448, 0.422478, 0.247971, 0.569821)),
    (${i}25, 'Sony Xperia 5 III', 256, 'black', 2021, 999.99, 899.99, 'FALSE', '1736538342000', (72,73,74), (1923456764345678976, 98765409877866654084, 1109876543450987650973), '{\"features\": [\"Snapdragon 888\", \"6.1-inch display\", \"Triple-camera system\"]}', (0.081106, 0.978278, 0.321892, 0.134594)),
    (${i}26, 'Google Pixel 5a 5G', 128, 'mostly black', 2021, 449.99, 349.99, 'TRUE', '1745080732000', (75,76,77), (2023456764345678976, 98765409877866654083, 1109876543450987650972), '{\"features\": [\"Snapdragon 765G\", \"6.34-inch display\", \"Dual-camera system\"]}', (0.893448, 0.432478, 0.257971, 0.579821)),
    (${i}27, 'BlackBerry Key2', 64, 'silver', 2018, 499.99, 399.99, 'FALSE', '1745080732000', (75,76,77), (2023456764345678976, 98765409877866654083, 1109876543450987650972), '{\"features\": [\"Snapdragon 660\", \"4.5-inch display\", \"Physical keyboard\"]}', (0.091106, 0.988278, 0.331892, 0.144594)),
    (${i}28, 'LG Velvet', 128, 'aurora silver', 2020, 599.99, 499.99, 'TRUE', '1751619286000', (78,79,80), (2123456764345678976, 98765409877866654082, 1109876543450987650971), '{\"features\": [\"Snapdragon 765G\", \"6.8-inch display\", \"Triple-camera system\"]}', (0.653448, 0.192478, 0.017971, 0.339821)),
    (${i}29, 'HTC Desire 21 Pro 5G', 128, 'purple', 2021, 499.99, 399.99, 'FALSE', '1758008742000', (81,82,83), (2223456764345678976, 98765409877866654081, 1109876543450987650970), '{\"features\": [\"Snapdragon 690\", \"6.7-inch display\", \"Quad-camera system\"]}', (-0.148894, 0.748278, 0.091892, -0.095406)),
    (${i}30, 'Motorola Moto G Power (2021)', 64, 'flash gray', 2021, 249.99, 149.99, 'TRUE', '1766538342000', (84,85,86), (2323456764345678976, 98765409877866654080, 1109876543450987650969), '{\"features\": [\"Snapdragon 662\", \"6.6-inch display\", \"Triple-camera system\"]}', (0.663448, 0.202478, 0.027971, 0.349821)),
    (${i}31, 'Sony Xperia 10 III', 128, 'black', 2021, 399.99, 299.99, 'FALSE', '1775080732000', (87,88,89), (2423456764345678976, 98765409877866654079, 1109876543450987650968), '{\"features\": [\"Snapdragon 690\", \"6.0-inch display\", \"Triple-camera system\"]}', (-0.138894, 0.758278, 0.101892, -0.085406)),
    (${i}32, 'Google Pixel 5', 128, 'just black', 2020, 699.99, 599.99, 'TRUE', '1781619286000', (90,91,92), (2523456764345678976, 98765409877866654078, 1109876543450987650967), '{\"features\": [\"Snapdragon 765G\", \"6.0-inch display\", \"Dual-camera system\"]}', (0.673448, 0.212478, 0.037971, 0.359821)),
    (${i}33, 'BlackBerry Motion', 32, 'black', 2017, 399.99, 299.99, 'FALSE', '1788008742000', (93,94,95), (2623456764345678976, 98765409877866654077, 1109876543450987650966), '{\"features\": [\"Snapdragon 625\", \"5.5-inch display\", \"Water-resistant\"]}', (-0.128894, 0.768278, 0.111892, -0.075406)),
    (${i}34, 'Nokia 8.3 5G', 128, 'polar night', 2020, 699.99, 599.99, 'TRUE', '1796538342000', (96,97,98), (2723456764345678976, 98765409877866654076, 1109876543450987650965), '{\"features\": [\"Snapdragon 765G\", \"6.81-inch display\", \"Quad-camera system\"]}', (0.683448, 0.222478, 0.047971, 0.369821)),
    (${i}35, 'LG G8 ThinQ', 128, 'aurora black', 2019, 849.99, 749.99, 'FALSE', '1805080732000', (99,100,101), (2823456764345678976, 98765409877866654075, 1109876543450987650964), '{\"features\": [\"Snapdragon 855\", \"6.1-inch display\", \"Dual-camera system\"]}', (-0.118894, 0.778278, 0.121892, -0.065406)),
    (${i}36, 'HTC Wildfire E1 lite', 32, 'black', 2021, 129.99, 109.99, 'TRUE', '1811619286000', (102,103,104), (2923456764345678976, 98765409877866654074, 1109876543450987650963), '{\"features\": [\"MediaTek Helio A20\", \"6.1-inch display\", \"Dual-camera system\"]}', (0.693448, 0.232478, 0.057971, 0.379821)),
    (${i}37, 'Motorola Moto G Stylus (2021)', 128, 'aurora black', 2021, 299.99, 199.99, 'FALSE', '1818008742000', (105,106,107), (3023456764345678976, 98765409877866654073, 1109876543450987650962), '{\"features\": [\"Snapdragon 678\", \"6.8-inch display\", \"Quad-camera system\"]}', (-0.108894, 0.788278, 0.131892, -0.055406)),
    (${i}38, 'Sony Xperia 10 Plus', 64, 'black', 2019, 299.99, 199.99, 'TRUE', '1826538342000', (108,109,110), (3123456764345678976, 98765409877866654072, 1109876543450987650961), '{\"features\": [\"Snapdragon 636\", \"6.5-inch display\", \"Dual-camera system\"]}', (0.703448, 0.242478, 0.067971, 0.389821)),
    (${i}39, 'Google Pixel 4 XL', 64, 'just black', 2019, 899.99, 799.99, 'FALSE', '1835080732000', (111,112,113), (3223456764345678976, 98765409877866654071, 1109876543450987650960), '{\"features\": [\"Snapdragon 855\", \"6.3-inch display\", \"Dual-camera system\"]}', (-0.098894, 0.798278, 0.141892, -0.045406)),
    (${i}40, 'BlackBerry Key2 LE', 64, 'space blue', 2018, 399.99, 299.99, 'TRUE', '1841619286000', (114,115,116), (3323456764345678976, 98765409877866654070, 1109876543450987650959), '{\"features\": [\"Snapdragon 636\", \"4.5-inch display\", \"Physical keyboard\"]}', (0.713448, 0.252478, 0.077971, 0.399821)),
    (${i}41, 'LG G7 ThinQ', 64, 'platinum gray', 2018, 599.99, 499.99, 'FALSE', '1848008742000', (117,118,119), (3423456764345678976, 98765409877866654069, 1109876543450987650958), '{\"features\": [\"Snapdragon 845\", \"6.1-inch display\", \"Dual-camera system\"]}', (-0.088894, 0.808278, 0.151892, -0.035406)),
    (${i}42, 'HTC Desire 12', 32, 'cool black', 2018, 199.99, 159.99, 'TRUE', '1856538342000', (120,121,122), (3523456764345678976, 98765409877866654068, 1109876543450987650957), '{\"features\": [\"MediaTek MT6739\", \"5.5-inch display\", \"Single camera\"]}', (0.723448, 0.262478, 0.087971, 0.409821)),
    (${i}43, 'Motorola Moto G6 Plus', 64, 'deep indigo', 2018, 299.99, 199.99, 'FALSE', '1865080732000', (123,124,125), (3623456764345678976, 98765409877866654067, 1109876543450987650956), '{\"features\": [\"Snapdragon 630\", \"5.9-inch display\", \"Dual-camera system\"]}', (-0.078894, 0.818278, 0.161892, -0.025406)),
    (${i}44, 'Sony Xperia XZ3', 64, 'forest green', 2018, 899.99, 799.99, 'TRUE', '1871619286000', (126,127,128), (3723456764345678976, 98765409877866654066, 1109876543450987650955), '{\"features\": [\"Snapdragon 845\", \"6.0-inch display\", \"Single camera\"]}', (0.733448, 0.272478, 0.097971, 0.419821)),
    (${i}45, 'Google Pixel 3', 128, 'not pink', 2018, 799.99, 699.99, 'FALSE', '1878008742000', (129,130,131), (3823456764345678976, 98765409877866654065, 1109876543450987650954), '{\"features\": [\"Snapdragon 845\", \"5.5-inch display\", \"Single camera\"]}', (-0.068894, 0.828278, 0.171892, -0.015406)),
    (${i}46, 'BlackBerry KEYone', 32, 'silver', 2017, 549.99, 449.99, 'TRUE', '1886538342000', (132,133,134), (3923456764345678976, 98765409877866654064, 1109876543450987650953), '{\"features\": [\"Snapdragon 625\", \"4.5-inch display\", \"Physical keyboard\"]}', (0.743448, 0.282478, 0.107971, 0.429821)),
    (${i}47, 'LG V30', 64, 'aurora black', 2017, 799.99, 699.99, 'FALSE', '1895080732000', (135,136,137), (4023456764345678976, 98765409877866654063, 1109876543450987650952), '{\"features\": [\"Snapdragon 835\", \"6.0-inch display\", \"Dual-camera system\"]}', (-0.058894, 0.838278, 0.181892, -0.005406)),
    (${i}48, 'HTC U11', 64, 'solar red', 2017, 649.99, 549.99, 'TRUE', '1901619286000', (138,139,140), (4123456764345678976, 98765409877866654062, 1109876543450987650951), '{\"features\": [\"Snapdragon 835\", \"5.5-inch display\", \"Single camera\"]}', (0.753448, 0.292478, 0.117971, 0.439821)),
    (${i}49, 'Motorola Moto Z2 Force', 64, 'super black', 2017, 799.99, 699.99, 'FALSE', '1908008742000', (141,142,143), (4223456764345678976, 98765409877866654061, 1109876543450987650950), '{\"features\": [\"Snapdragon 835\", \"5.5-inch display\", \"Dual-camera system\"]}', (-0.048894, 0.848278, 0.191892, 0.004594)),
    (${i}50, 'Sony Xperia XZ Premium', 64, 'luminous chrome', 2017, 699.99, 599.99, 'TRUE', '1916538342000', (144,145,146), (4323456764345678976, 98765409877866654060, 1109876543450987650949), '{\"features\": [\"Snapdragon 835\", \"5.46-inch display\", \"Single camera\"]}', (-0.038894, 0.858278, 0.201892, 0.014594));" >> $output_file

done

mysql -h0 -P9306 < $output_file

mysql -h0 -P9306 -e "FLUSH RAMCHUNK tbl; SHOW TABLES; SELECT COUNT(*) FROM tbl;"

