diff --git a/mycgi/gomi.rb b/mycgi/gomi.rb index c025b06..ba7c136 100755 --- a/mycgi/gomi.rb +++ b/mycgi/gomi.rb @@ -8,6 +8,7 @@ c = CGI.new(:accept_charset => "UTF-8") csv = CSV.read("gomi.csv", headers:true) db = SQLite3::Database.new("tmpdb/gomi.sq3") + db.execute_batch(<<~EOF) DROP TABLE IF EXISTS gomi; CREATE TABLE IF NOT EXISTS gomi(name text,type text,remark text,kana text,kata text,roma text); @@ -23,15 +24,17 @@ db.results_as_hash = true result = db.execute("SELECT * FROM gomi where name||kana||kata||roma LIKE '%#{trash}%';") - print ("Content-type: text/html; charset=utf-8") - print (" - - 検索結果 - - ") - result.each{|row| - printf("
品名 : 「%s」
ごみ区分 : 「%s」

備考 : %s
-------------------------------------------------------------------------------",row["name"], row["type"], row["remark"])} - print "\n" -print "" +print("Content-type: text/html; charset=utf-8 + + +検索結果 + + +") +result.each{|row| +printf("
品名 : 「%s」
ごみ区分 : 「%s」

備考 : %s
-------------------------------------------------------------------------------",row["name"], row["type"], row["remark"])} +puts(" + +") end -db.execute("END;") \ No newline at end of file +db.execute("END;") diff --git a/mycgi/test1.rb b/mycgi/test1.rb index b89d581..5e62684 100755 --- a/mycgi/test1.rb +++ b/mycgi/test1.rb @@ -36,17 +36,14 @@ # end print("Content-type: text/html; charset=utf-8 - 検索結果 ") - db.each {|row| printf("
ID : 「%s」
品名 : 「%s」
ごみ区分 : 「%s」

備考 : %s
-------------------------------------------------------------------------------",row["ID"],row["品名"], row["ごみ区分"],row["備考"])} - puts(" ") diff --git a/mycgi/tmpdb/gomi.sq3 b/mycgi/tmpdb/gomi.sq3 index b7f7c47..abd5da9 100644 --- a/mycgi/tmpdb/gomi.sq3 +++ b/mycgi/tmpdb/gomi.sq3 Binary files differ