Description:
I have a csv file named hardware.txt
containing the following...
"0","Desktop","Dell","OptiPlex GX620","CGTQS81"," Intel(R) Pentium(R) 4 CPU 2.80GHz","2794","N/A","329555.1","Unknown","N/A","N/A","WMI-SERIAL","1024x768","503","SCIARRA, JOHN","2005-07-15 16:05:11","2009-04-11 03:09:16"
"1","Laptop","IBM","2653R3U","78ZHM76","Mobile Intel(R) Pentium(R) 4 - M CPU 2.00GHz","1998","N/A","N/A","Dell","N/A","N/A","WMI-ERROR","1600x1200","1023","","2004-10-08 14:49:20","2006-07-10 10:41:50"
"2","Desktop","Dell","OptiPlex GX260","5WTPS11"," Intel(R) Pentium(R) 4 CPU 2.00GHz","1992","23456890","N/A","Dell","115 FS","N/A","WMI-SERIAL","1280x1024","510","","2004-01-21 00:24:03","2005-08-19 19:04:48"
"3","N/A","N/A","N/A","N/A","Unknown","448","N/A","N/A","Unknown","N/A","N/A","WMI-SERIAL","1024x768","512","N/A","2005-07-15 16:05:11","2005-10-11 15:08:35"
"4","Desktop","Compaq","ENP333/6.4","N/A","Intel Pentium(R) III processor","549","N/A","N/A","Dell","N/A","N/A","N/A","1024x768","192","","2004-01-22 13:41:56","2036-01-24 13:40:45"
"5","Desktop","Dell","OptiPlex GX620","8040W81"," Intel(R) Pentium(R) 4 CPU 2.80GHz","2793","N/A","N/A","Dell","N/A","N/A","WMI-SERIAL","1024x768","503","","2005-11-28 11:05:27","2007-06-14 10:53:36"
"6","Desktop","Dell","OptiPlex GX620","9SVBV81"," Intel(R) Pentium(R) 4 CPU 2.80GHz","2793","N/A","N/A","Unknown","N/A","N/A","WMI-SERIAL","1024x768","503","N/A","2005-11-18 10:05:59","2007-01-08 09:18:33"
"7","Laptop","Dell","Latitude D600","7PTPH31","Family: 6,Model: 9,Step: 5","1301","123564897","N/A","Dell","","","","1024x768","512","","2004-01-29 13:29:16","2036-01-24 07:33:12"
"8","Desktop","Dell","OptiPlex GX620","CPN1Q81"," Intel(R) Pentium(R) 4 CPU 2.80GHz","2793","N/A","N/A","Unknown","N/A","N/A","WMI-SERIAL","1024x768","503","N/A","2005-08-05 01:56:55","2006-11-26 13:11:48"
"9","Desktop","Dell","OptiPlex GX280","G922581"," Intel(R) Pentium(R) 4 CPU 2.80GHz","2793","N/A","N/A","Unknown","N/A","N/A","WMI-SERIAL","1024x768","1015","N/A","2005-03-08 13:35:17","2007-09-10 09:50:15"
I use the mysqlimport command line tool to load the data in that file into the sabrina2 database into table named the same as the base name of the file to imported.
CREATE TABLE `hardware` (
`uid` mediumint(9) unsigned NOT NULL,
`cputype` varchar(10) DEFAULT '',
`cpumake` varchar(30) DEFAULT '',
`cpumodel` varchar(30) DEFAULT '',
`cpuserial` varchar(30) DEFAULT '',
`cpudescr` varchar(100) DEFAULT '',
`cpuspeed` mediumint(9) unsigned DEFAULT '0',
`cpuassettag` varchar(30) DEFAULT '',
`cpuordernum` varchar(30) DEFAULT NULL,
`monitormake` varchar(30) DEFAULT '',
`monitormodel` varchar(30) DEFAULT '',
`monitorserial` varchar(30) DEFAULT '',
`monitorassettag` varchar(30) DEFAULT '',
`screenres` varchar(10) DEFAULT '',
`memory` mediumint(9) unsigned DEFAULT '0',
`installerName` varchar(64) DEFAULT NULL,
`bornondate` datetime DEFAULT '0000-00-00 00:00:00',
`lastupdated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
using this command line
mysqlimport -uroot -ppassword -v -d --fields-terminated-by=',' --fields-enclosed-by='"' --fields-escaped-by='\' sabrina2 /home/batch/hardware.txt
and get the following output and error...
Connecting to localhost
Selecting database sabrina2
Deleting the old data from table hardware
Loading data from SERVER file: /home/batch/hardware.txt into hardware
mysqlimport: Error: 1146, Table 'sabrina2.new_installs' doesn't exist, when using table: hardware
How to repeat:
copy above data into text file named hardware.txt
use above command line to try and import the data.