views:

37

answers:

2

I have tried the below code for laoding the inline file in drupal db

 $sql = "LOAD DATA INFILE '".db_escape_string($this->file_name).
         "' INTO TABLE `".$this->table_name.
         "` FIELDS TERMINATED BY '".db_escape_string($this->field_separate_char).
         "' OPTIONALLY ENCLOSED BY '".db_escape_string($this->field_enclose_char).
         "' ESCAPED BY '".db_escape_string($this->field_escape_char).
         "' ".
         ($this->use_csv_header ? " IGNORE 1 LINES " : "")
         ."(`".implode("`,`", $this->arr_csv_columns)."`)";
  $res = db_query($sql);
  $this->error = mysql_error();

I got the error as but the file was present in the folder

user warning: File 'http:\localhost\example\sites\default\files\example_1.csv' not found (Errcode: 22) query: LOAD DATA INFILE 'http://localhost/example/sites/default/files/example_1.csv' INTO TABLE temp_21_10_2010_06_38_00 FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\' IGNORE 1 LINES (PROGRAMNAME,OFFLINE,ONLINE,INSTOCK) in C:\wamp\www\example\sites\all\modules\importmodule\Quick_CSV_import.php on line 65.

On line 65 the above php code $res = db_query($sql); is present.

A: 

Perhaps is it due to open_files_limit ?

MatTheCat
A: 

you need to specify the full/absolute or a relative path to your csv file not a URL

load data infile '/myproj/imports/example_1.csv' into table...

load data infile 'c:\\myproj\\imports\\example_1.csv' into table...

suggest you check the manual again http://dev.mysql.com/doc/refman/5.1/en/load-data.html

f00
The above same code works fine in php but i cannot get it through drupal.
ugesh.gali