Я использую Laravel, и мне нужно загрузить объем (~ 1 миллион) данных (в файле .xlsx) в MySQL, используя Laravel .... < /p>
В настоящее время я загружаю данные ближе к 200K, и он загружается в MySQL с phpoffice-phpspreadsheet-пакетом ... < /p>
getActiveSheet();
$row_limit = $sheet->getHighestDataRow();
$column_limit = $sheet->getHighestDataColumn();
$row_range = range( 2, $row_limit );
$column_range = range( 'AH', $column_limit );
$startcount = 2;
$data = array();
$counter = 0;
foreach ( $row_range as $row ) {
$counter++;
if($counter%5 == 0)
{
info('Next 5');
}
$data = [
'id' =>$sheet->getCell( 'A' . $row )->getValue(),
'ACNo' => $sheet->getCell( 'B' . $row )->getValue(),
'PartNo' => $sheet->getCell( 'C' . $row )->getValue(),
'SectionNo' => $sheet->getCell( 'D' . $row )->getValue(),
'SlNo' => $sheet->getCell( 'E' . $row )->getValue(),
'HouseNo' =>$sheet->getCell( 'F' . $row )->getValue(),
'VHouseNo' =>$sheet->getCell( 'G' . $row )->getValue(),
'EName' =>$sheet->getCell( 'H' . $row )->getValue(),
'VEName' =>$sheet->getCell( 'I' . $row )->getValue(),
'sex' =>$sheet->getCell( 'J' . $row )->getValue(),
'RName' =>$sheet->getCell( 'K' . $row )->getValue(),
'VRName' =>$sheet->getCell( 'L' . $row )->getValue(),
'RType' =>$sheet->getCell( 'M' . $row )->getValue(),
'Age' =>$sheet->getCell( 'N' . $row )->getValue(),
'IDCardNo' =>$sheet->getCell( 'O' . $row )->getValue(),
'statustype' =>$sheet->getCell( 'P' . $row )->getValue(),
'Addition' =>$sheet->getCell( 'Q' . $row )->getValue(),
'ContactNo' =>$sheet->getCell( 'R' . $row )->getValue(),
'Address' =>$sheet->getCell( 'S' . $row )->getValue(),
'VAddress' =>$sheet->getCell( 'T' . $row )->getValue(),
'PSName' =>$sheet->getCell( 'U' . $row )->getValue(),
'VPSName' =>$sheet->getCell( 'V' . $row )->getValue(),
'whatsappNumber' =>$sheet->getCell( 'W' . $row )->getValue(),
'caste' =>$sheet->getCell( 'X' . $row )->getValue(),
'casteCategory' =>$sheet->getCell( 'Y' . $row )->getValue(),
'education' =>$sheet->getCell( 'Z' . $row )->getValue(),
'currentCity' =>$sheet->getCell( 'AA' . $row )->getValue(),
'currentDistrict' =>$sheet->getCell( 'AB' . $row )->getValue(),
'currentState' =>$sheet->getCell( 'AC' . $row )->getValue(),
'livelihood' =>$sheet->getCell( 'AD' . $row )->getValue(),
'voted' =>$sheet->getCell( 'AE' . $row )->getValue(),
'support' =>$sheet->getCell( 'AF' . $row )->getValue(),
'created_at' =>$sheet->getCell( 'AG' . $row )->getValue(),
'updated_at' =>$sheet->getCell( 'AH' . $row )->getValue(),
];
$startcount++;
Voter::create($data);
}
}
catch (Exception $e)
{
// $error_code = $e->errorInfo[0];
//
// echo $error_code;
echo $e;
exit();
}
}
< /code>
Здесь < /p>
$extension is the extension of file which should be .xlsx
[/code]
И мне нужно оптимизировать поток .... Так что я могу загрузить почти 1 миллион данных, используя этот метод
Подробнее здесь: https://stackoverflow.com/questions/737 ... timization
Laravel: (1 м) загрузка данных в MySQL с оптимизацией ⇐ Php
Кемеровские программисты php общаются здесь
-
Anonymous
1754079649
Anonymous
Я использую Laravel, и мне нужно загрузить объем (~ 1 миллион) данных (в файле .xlsx) в MySQL, используя Laravel .... < /p>
В настоящее время я загружаю данные ближе к 200K, и он загружается в MySQL с phpoffice-phpspreadsheet-пакетом ... < /p>
getActiveSheet();
$row_limit = $sheet->getHighestDataRow();
$column_limit = $sheet->getHighestDataColumn();
$row_range = range( 2, $row_limit );
$column_range = range( 'AH', $column_limit );
$startcount = 2;
$data = array();
$counter = 0;
foreach ( $row_range as $row ) {
$counter++;
if($counter%5 == 0)
{
info('Next 5');
}
$data = [
'id' =>$sheet->getCell( 'A' . $row )->getValue(),
'ACNo' => $sheet->getCell( 'B' . $row )->getValue(),
'PartNo' => $sheet->getCell( 'C' . $row )->getValue(),
'SectionNo' => $sheet->getCell( 'D' . $row )->getValue(),
'SlNo' => $sheet->getCell( 'E' . $row )->getValue(),
'HouseNo' =>$sheet->getCell( 'F' . $row )->getValue(),
'VHouseNo' =>$sheet->getCell( 'G' . $row )->getValue(),
'EName' =>$sheet->getCell( 'H' . $row )->getValue(),
'VEName' =>$sheet->getCell( 'I' . $row )->getValue(),
'sex' =>$sheet->getCell( 'J' . $row )->getValue(),
'RName' =>$sheet->getCell( 'K' . $row )->getValue(),
'VRName' =>$sheet->getCell( 'L' . $row )->getValue(),
'RType' =>$sheet->getCell( 'M' . $row )->getValue(),
'Age' =>$sheet->getCell( 'N' . $row )->getValue(),
'IDCardNo' =>$sheet->getCell( 'O' . $row )->getValue(),
'statustype' =>$sheet->getCell( 'P' . $row )->getValue(),
'Addition' =>$sheet->getCell( 'Q' . $row )->getValue(),
'ContactNo' =>$sheet->getCell( 'R' . $row )->getValue(),
'Address' =>$sheet->getCell( 'S' . $row )->getValue(),
'VAddress' =>$sheet->getCell( 'T' . $row )->getValue(),
'PSName' =>$sheet->getCell( 'U' . $row )->getValue(),
'VPSName' =>$sheet->getCell( 'V' . $row )->getValue(),
'whatsappNumber' =>$sheet->getCell( 'W' . $row )->getValue(),
'caste' =>$sheet->getCell( 'X' . $row )->getValue(),
'casteCategory' =>$sheet->getCell( 'Y' . $row )->getValue(),
'education' =>$sheet->getCell( 'Z' . $row )->getValue(),
'currentCity' =>$sheet->getCell( 'AA' . $row )->getValue(),
'currentDistrict' =>$sheet->getCell( 'AB' . $row )->getValue(),
'currentState' =>$sheet->getCell( 'AC' . $row )->getValue(),
'livelihood' =>$sheet->getCell( 'AD' . $row )->getValue(),
'voted' =>$sheet->getCell( 'AE' . $row )->getValue(),
'support' =>$sheet->getCell( 'AF' . $row )->getValue(),
'created_at' =>$sheet->getCell( 'AG' . $row )->getValue(),
'updated_at' =>$sheet->getCell( 'AH' . $row )->getValue(),
];
$startcount++;
Voter::create($data);
}
}
catch (Exception $e)
{
// $error_code = $e->errorInfo[0];
//
// echo $error_code;
echo $e;
exit();
}
}
< /code>
Здесь < /p>
$extension is the extension of file which should be .xlsx
[/code]
И мне нужно оптимизировать поток .... Так что я могу загрузить почти 1 миллион данных, используя этот метод
Подробнее здесь: [url]https://stackoverflow.com/questions/73703848/laravel-1-m-bulk-data-upload-to-the-mysql-with-optimization[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия