在 2009-06-14日的 18:33 +0100,Simon Slavin写道: > On 14 Jun 2009, at 4:43pm, Kermit Mei wrote: > > > But I want to insert values from a file underlinux, > > and I don't want write any code for it. > > Okay, that kind of information is important enough to appear in your / > first/ post. > > > I hope sqlite3 > .import FILE > > can do it > > It can't. However, if you are good with a spreadsheet you can get > your data in two ways without any programming. One is to add your own > column for the unique id numbers and use a trivial calculation to fill > it. The other is to turn your text file into a set of import commands > to do the importing for you. Then you can use .read instead. The > first one is easy, for the second one ... > > Import your data file into a spreadsheet, and make sure you have your > values in columns of the spreadsheet. Then create a new column which > has the appropriate INSERT command to insert those values. In my > favourite spreadsheet application this would be something like > > (formula to go in cell C1) > > =CONCAT("INSERT mytable (name, age) VALUES ('",a1,"', "+b1+");") > > Then fill the C column downwards with copies of that formula. > > Once you have that, copy the contents of column C, paste it into a > text file, and you have all the instructions you'd need to put your > data into that table. Then use the .read command in sqlite to run > those commands. > > Simon.
Yes, I see. In fact, my manager asked me to provide a txt file for the others to import something into the database. And the ones, who will import data may not understand database at all. Maybe I'd better to write a GUI for them:P Thank you, Simon:P _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users