load-data-infile

Parameterizing file name in MYSQL LOAD DATA INFILE

Hi Is there a way to dynamically specify a file name in the LOAD DATA INFILE? Can it be parameterized like for instance (syntax may be incorrect) LOAD DATA INFILE '$filename'? ...

Trigger to skip certain inserts during LOAD DATA INFILE

First of, a simplified version: I am wondering if I can create a trigger to activate during INSERT (it's actually LOAD DATA INFILE) and NOT enter records for an RMA already in my table? I have a table that has no records that are unique. Some may be legitimate duplicates but there is one field that I can use to know if the data has bee...

Import CSV to mysql

I have created a database and table. I have also created all the fields i will be needing. I have created 46 fields including 1 that is my ID for the row. The CSV doesn't contain the id field, nor does it contain the headers for the columns. I am new to all of this but have been trying to figure this out. I'm not on here being lazy askin...

LOAD DATA INFILE not working with FIELDS TERMINATED BY

I'm using the sql below in a php script: $sql1 = "LOAD DATA LOCAL INFILE 'test1.csv' INTO TABLE number1 (order_num,pname)"; $sql2 = "LOAD DATA LOCAL INFILE 'test1.csv' INTO TABLE number1 (order_num,pname) FIELDS TERMINATED BY ':'"; if ($result = $mysqli->query($sql)) { printf("<br>Section 4: %s",$mysqli->error); printf("|$result...

How to upload timestamp data from a file into mysql

shell> cat /data/mysql/tm.sql 1276609796 1276606325 mysql> CREATE TABLE `tm_table` ( f TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP); Query OK, 0 rows affected mysql> LOAD DATA INFILE '/data/mysql/tm.sql' INTO TABLE tm_table; Query OK, 2 rows affected Records: 2 Deleted: 0 Skipped: 0 Warnings: 2 mysql> SHOW WARNINGS; +---------+------+...

LOAD DATA INFILE REPLACE doesn't seem to work with multiple fields?

I'm loading a file into a table with php. I create a table like this: CREATE TABLE IF NOT EXISTS $table ( `id` INT AUTO_INCREMENT PRIMARY KEY, `order` INT DEFAULT 0, `data` VARCHAR(200) UNIQUE, `cur_timestamp` TIMESTAMP DEFAULT NOW())"; And fill it from a text file like this: LOAD DATA LOCAL INFILE '".$file ."' REPLACE INTO TABLE $...

Neither LOAD DATA LOCAL..REPLACE or INSERT..ON DUPLICATE are working. Something wrong with my table structure?

I'm loading files into a table with php. I create a table like this: CREATE TABLE IF NOT EXISTS $table ( `id` INT AUTO_INCREMENT PRIMARY KEY, `order` INT DEFAULT 0, `data` VARCHAR(200) UNIQUE KEY, `cur_timestamp` TIMESTAMP DEFAULT NOW())" And fill it from a text file like this: LOAD DATA LOCAL INFILE '".$file ."' REPLACE INTO TABLE...

mysql load data infile where clause

I need to update existing rows in table with load data infile based on some condition, is this possible? load data infile 'E:/xxx.csv' into table tld_tod @aaa, @xxx_date, @ccc fields terminated by ',' LINES TERMINATED BY '\r\n' set xxx = str_to_date(@xxx_date, '%d-%b-%y') where xxx is not null and aaa=@aaa ...

Insert rows of states and iso's from comma separated textfile into webbased Mysql

I'm building an international webshop and in the part where a customer has to fill in the address I wonder how I insert the rows in a comma separated text file with a list of stats in my web based MySQL? Example AM,04,"Geghark'unik'" AM,05,"Kotayk'" AM,06,"Lorri" AM,07,"Shirak" AM,08,"Syunik'" AM,09,"Tavush" AM,10,"Vayots' Dzor" I fou...

mysql load data infile can't get stat of file Errcode: 2

I have looked all over and found no solution, any help on this would be great. Query: LOAD DATA INFILE '/Users/name/Desktop/loadIntoDb/loadIntoDB.csv' INTO TABLE `tba`.`tbl_name` FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES ( field1, field2, field3 ) Error: Can't get stat of '/Users/name/Desktop/loadIntoDb/lo...

mysql "datetime NOT NULL DEFAULT '1970-01-01' " gets turned to 0000-00-00 00:00:00

I have a column created as `date_start` datetime NOT NULL DEFAULT '1970-01-01' However when I upload data from a CSV file with the LOAD DATA command with a blank entry for date_start the value saved is 0000-00-00 00:00:00 ? ...

Some data is modified without apparent reason when importing .cvs to a MySQL db, any idea?

So I'm impoting a 80000+ lines .cvs files to a MySQL database, using Import CVS via LOAD DATA in phpMyAdmin, and it seems to work fine, there are no error messages. Problem is, ater the import, all lines in the table, starting with line 24002 have the same number in one of my database fields, and this number doesn't even exist in the .c...

Importing excel data in to mysql table using command line

Hi, I have lot of excel files to import in mysql table. Is there any mysql command/procedure which directly takes excel file and import it in table one by one? or any simpler way to to this task in few steps? ...

What file and directory permissions are required for MySQL LOAD DATA INFILE?

I have a script that is trying to load some data into MySQL with LOAD DATA INFILE. For some reason, it works if the file is in the /tmp directory, but not if the file is in another directory with identical permissions. I can't find any way to get MySQL to import data from outside the /tmp directory, or the database directory, but I can't...

How does MySQL handle exact IEEE 754 representations?

Is there a way to load exact octal, hex or binary representations of IEEE 754 floats (as text) into a MySQL table using the correct single- or double-precision data type? E.g. the number pi written as 1078530011 or 40490fdb (single-precision). Preferably with LOAD DATA INFILE/mysqlimport, in the interests of speed... ...

LOAD DATA LOCAL INFILE keeps crashing

Hello folks, I am loading a large text file into my db through LOAD DATA. The file is about 122,000 lines long. Let alone, The db is designed to be triggered on AFTER INSERT's on that table. What happens exactly is that the query begin executing, keeps executing for like 15-20 mins and then it returns Error Code: 2013 Lost connection ...