I have about 200k rows to import into Postgresql database. I found that I should use pg_copy_from function. I tried it, but it should return true or false and it returns null. And of course, it doesn't insert anything into db.
pg_copy_from($this->connection, $table, $data);
I also tried alternative pg_put_line
pg_query($this->connection, "copy $table from stdin");
foreach ($data as $row) {
pg_put_line($this->connection, implode('\t', $row));
}
pg_put_line($this->connection, "\\.\n");
pg_end_copy($this->connection);
It didn't help. It doesn't throw any error and I have no idea what is the problem. Do you have any idea why it returns null or how to solve this problem?
EDIT: my row looks like this
2019-04-01\t8\t3\tH\tA\t0021\t\\N\t\\N\t\\N\t\\N\t15\t\\N\t0\t0\t0\t0
and I have 16 columns ... I can insert the same data using pdo query