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

[eluser]megabyte[/eluser]
Solved, I had a silly typo.


I tried load data infile.

Any ideas why I am getting this error?

Code:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near 'products product_code FIELDS TERMINATED
BY ',' OPTIONALLY ENCLOSED BY '"' LINES ' at line 1

LOAD DATA INFILE '/tmp/CATALOGUE.csv' REPLACE INTO products product_code FIELDS TERMINATED
BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' (id, cat_id, product_code,
gst, case_size, list_order, product_name, price1, price2, price3, price4, price5)

Here is my table structure, the last 3 columns in the table do not exist inthe csv and are to be updated later.

Code:
--
-- Table structure for table `products`
--

CREATE TABLE IF NOT EXISTS `products` (
  `id` int(11) NOT NULL auto_increment,
  `cat_id` varchar(20) NOT NULL,
  `product_code` varchar(10) NOT NULL,
  `gst` varchar(3) default NULL,
  `case_size` float NOT NULL,
  `list_order` int(11) NOT NULL,
  `product_name` text NOT NULL,
  `price1` decimal(11,2) NOT NULL,
  `price2` decimal(11,2) NOT NULL,
  `price3` decimal(11,2) NOT NULL,
  `price4` decimal(11,2) NOT NULL,
  `price5` decimal(11,2) NOT NULL,
  `description` text NOT NULL,
  `photo` varchar(255) NOT NULL,
  `created` date NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `product_code` (`product_code`),
  KEY `Id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Will this still work if none of the coumns in the csv are named? The csv just starts off with rows of data right away


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