Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-05-2007, 08:44 AM
|
#1
|
|
Member
Registered: Sep 2006
Location: India
Distribution: suse10.2
Posts: 127
Rep:
|
mysql insert using bash script
hi ,
THere is one csv file in that there are 100 lines.
i have to insert each line into mysql table?
plz give me the bash script!!
i am unble to solve..
eg
1.csv
1,2,3,4,5
1,3,4,6,8
there is mysql table .
i have to insert these values into table!!
plz help
|
|
|
|
07-05-2007, 09:03 AM
|
#2
|
|
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,006
Rep: 
|
Hi
Take a look at:
http://dev.mysql.com/doc/refman/5.0/en/load-data.html
You don't write the command in bash, but in mysql. So something like:
mysql databasename
LOAD DATA INFILE '1.csv' INTO TABLE TheTable FIELDS TERMINATED BY ',';
|
|
|
|
07-06-2007, 02:59 AM
|
#3
|
|
Member
Registered: Sep 2006
Location: India
Distribution: suse10.2
Posts: 127
Original Poster
Rep:
|
hi , its very useful data but..
i have table called rss
in that there are attributes
one , two ,three ,four,five
desc rss
-> ;
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| one | varchar(255) | YES | | NULL | |
| two | varchar(255) | YES | | NULL | |
| three | varchar(255) | YES | | NULL | |
| four | varchar(255) | YES | | NULL | |
| five | varchar(255) | YES | | NULL | |
| six | varchar(255) | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+
6 rows in set (0.00 sec)
where as my rss fields are
1,2,3,4,5
now i want to insert 1 in one,2 in two........
plz help
|
|
|
|
07-07-2007, 04:52 AM
|
#4
|
|
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,006
Rep: 
|
Quote from the manual page:
Quote:
You can also discard an input value by assigning it to a user variable and not assigning the variable to a table column:
LOAD DATA INFILE 'file.txt'
INTO TABLE t1
(column1, @dummy, column2, @dummy, column3);
|
So perhaps:
LOAD DATA INFILE 'file.txt'
INTO TABLE rss
(one two, three, four, five, @dummy);
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:19 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|