Welcome Guest, Not a member yet? Register   Sign In
importing a csv into the db
#22

[eluser]alberto24[/eluser]
[quote author="ray73864" date="1225857031"]as i said before, you need to copy the file to a temporary directory, php can copy to /tmp/ so create an upload script that uploads the file to /tmp/ then use that in the load data infile and when the import is complete have php 'unlink' the file.[/quote]

same error with the tmp file

here's the full error:

Code:
A Database Error Occurred
Error Number: 1045

Access denied for user '369706_cloud1'@'%' (using password: YES)

LOAD DATA INFILE "/tmp/moo.csv" REPLACE INTO TABLE csvtest FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' (f_name, l_name, country, @dummy, phone)

and full code

Code:
function index ()
    {  
    if ( !copy("/mnt/target03/fullpath/csv/test1.csv", "/tmp/moo_item.csv") )
            $data['message'] = "Could not copy CSV file to temporary directory ready for importing.";

        $query = $this->db->query("LOAD DATA INFILE \"/tmp/moo_item.csv\" REPLACE INTO TABLE csvtest FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n' (f_name, l_name, country, @dummy, phone)",array('/tmp/moo_item.csv'));
        
        if ($query) {
            $data['message'] = "All items imported successfully.";
        } else {
            $data['message'] = "Import failed.";
        }
        
        unlink ("/tmp/moo_item.csv");

    }


Messages In This Thread
importing a csv into the db - by El Forum - 11-03-2008, 08:27 PM
importing a csv into the db - by El Forum - 11-03-2008, 09:34 PM
importing a csv into the db - by El Forum - 11-04-2008, 04:15 AM
importing a csv into the db - by El Forum - 11-04-2008, 05:06 AM
importing a csv into the db - by El Forum - 11-04-2008, 05:12 AM
importing a csv into the db - by El Forum - 11-04-2008, 05:22 AM
importing a csv into the db - by El Forum - 11-04-2008, 05:26 AM
importing a csv into the db - by El Forum - 11-04-2008, 05:46 AM
importing a csv into the db - by El Forum - 11-04-2008, 05:49 AM
importing a csv into the db - by El Forum - 11-04-2008, 08:42 AM
importing a csv into the db - by El Forum - 11-04-2008, 11:09 AM
importing a csv into the db - by El Forum - 11-04-2008, 11:13 AM
importing a csv into the db - by El Forum - 11-04-2008, 11:27 AM
importing a csv into the db - by El Forum - 11-04-2008, 02:31 PM
importing a csv into the db - by El Forum - 11-04-2008, 02:46 PM
importing a csv into the db - by El Forum - 11-04-2008, 03:00 PM
importing a csv into the db - by El Forum - 11-04-2008, 03:16 PM
importing a csv into the db - by El Forum - 11-04-2008, 03:29 PM
importing a csv into the db - by El Forum - 11-04-2008, 03:39 PM
importing a csv into the db - by El Forum - 11-04-2008, 03:50 PM
importing a csv into the db - by El Forum - 11-04-2008, 03:54 PM
importing a csv into the db - by El Forum - 11-04-2008, 03:59 PM
importing a csv into the db - by El Forum - 11-04-2008, 05:50 PM
importing a csv into the db - by El Forum - 11-04-2008, 05:53 PM
importing a csv into the db - by El Forum - 11-04-2008, 06:00 PM
importing a csv into the db - by El Forum - 11-04-2008, 06:35 PM
importing a csv into the db - by El Forum - 11-04-2008, 06:45 PM
importing a csv into the db - by El Forum - 11-21-2009, 02:32 PM
importing a csv into the db - by El Forum - 11-22-2009, 01:05 AM
importing a csv into the db - by El Forum - 08-04-2011, 01:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB