Note that there are some explanatory texts on larger screens.

plurals
  1. POTimeout importing huge txt in mysql
    primarykey
    data
    text
    <p>I'm trying to import a huge txt in mysql.<br> it is my first attempt to use php and mysql so I'm not sure where is the problem.<br> I have a txt of almost the 4 million row and I need to store it in a db.<br> I wrote this pice of php to do the job:<br></p> <pre><code>$con=mysqli_connect('localhost', 'root', 'root', 'commuting'); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $handle = fopen("matrix_pendo2001.txt", "r") or die("Couldn't get handle"); if ($handle) { while (!feof($handle)) { $line = fgets($handle, 4096); $a = substr($line,0,3); $b = substr($line,4,3); $c = substr($line,8,1); $d = substr($line,10,1); $e = substr($line,12,1); $f = substr($line,14,3); $g = substr($line,18,3); $h = substr($line,22,3); $i = substr($line,26,1); $l = substr($line,28,2); $m = substr($line,31,1); $n = substr($line,33,1); $o = substr($line,35,8); $sql="INSERT INTO ita (ProvRes, ComRes, Sesso, Motivo, Luogo, ProvLav, ComLav, StatExt, MercPrev, Mezzo, Ora, Tempo, Num) VALUES ('$a', '$b', '$c', '$d', '$e', '$f', '$g', '$h', '$i', '$l', '$m', '$n', '$o')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "record '&lt;b&gt;" . $line . "'&lt;/b&gt; added. &lt;br/&gt;"; } fclose($handle); } mysqli_close($con); </code></pre> <p>The script seems to work well, but I can't get all the row in the db.<br> after less than 1 million the script ends without apparent error.<br> I have set the max_execution_time to 0 and increased the memory_limit to 2048MB but nothing change.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload