I can't test this since I don't have your file or DB, but it should put you on 
the right track. This example assumes only 1 IP address on each line and will 
ignore any other tokens.

FOR /F "tokens=1" %%A IN "machinelist.txt" DO (
  sqlite3.exe dropped.db "INSERT INTO DropDB_log(date, ip_address, status) VALUES 
(%DATE%, %%A, '%STATUS%');"
)

(Notice all the unnecessary DB quotes and backticks removed - those are only needed when the string doesn't make sense in machine terms, and these all are o.k.)

HTH,
Ryan


On 2016/09/26 9:34 PM, jungle Boogie wrote:
Hi All,


I'm attempting to make a windows batch file that reads a text file and
inserts a new record for each entry:

sqlite3.exe dropped.db  "INSERT INTO
`DropDB_log`(`date`,`ip_address`,`status`) VALUES
(%DATE%,readfile('machinelist.txt'),'%STATUS%');"

Right now, it does this:
date,ip_address,status20160926,128.10.10.1
128.10.10.3
128.10.10.4
128.10.10.5,up


I'd like this:
20160926,128.10.10.1,up
20160926,128.10.10.3,up
20160926,128.10.10.4,down
20160926,128.10.10.5,up

Will the readfile + the separator command allow this kind of hackery
in windows batch files?

Thanks!



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to