http://storehouse.sakura.ne.jp/viewvc/viewvc.cgi/tcsql/?root=svn
文字列リテラルのエスケープとか、エラー処理は適当。
#!/usr/bin/ruby require 'rubygems' require 'tcsql' require 'pp' include TokyoCabinet def go(sql) puts <<EOS ----- #{sql.strip} ----- EOS pp TDBSQL.query(sql) end go(%q{ select * from casket.tct }) go(%q{ select name from casket.tct }) go(%q{ select * from casket.tct where age > 30 }) go(%q{ select * from casket.tct where age = 30 }) go(%q{ select * from casket.tct where age = 30 and name = 'makio' }) go(%q{ select * from casket.tct where age in (30, 31) }) go(%q{ insert into casket.tct (name, age) values ('ka''kioe', 25.3) }) go(%q{ select * from casket.tct where age >= 25.3 }) go(%{ update casket.tct set name = '#{Time.now.to_i}', time = '#{Time.now}' where age = 25.3 }) go(%q{ select * from casket.tct where age = 25.3 }) go(%q{ delete from casket.tct where age = 25.3 }) go(%q{ select * from casket.tct where age = 25.3 }) go(%q{ select * from casket.tct })
-
-
-
- -
-
-
select * from casket.tct
-
-
-
- -
-
-
[{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"falcon", "skill"=>"cook,blog", "lang"=>"ja", "age"=>"31"},
{"name"=>"ozma", "skill"=>"song,dance", "lang"=>"en"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"ho'ge", "age"=>"25"},
{"name"=>"ho'ge", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"}]
-
-
-
- -
-
-
select name from casket.tct
-
-
-
- -
-
-
[{"name"=>"mikio"},
{"name"=>"falcon"},
{"name"=>"ozma"},
{"name"=>"mikio"},
{"name"=>"mikio"},
{"name"=>"mikio"},
{"name"=>"mikio"},
{"name"=>"makio"},
{"name"=>"makio"},
{"name"=>"makio"},
{"name"=>"ho'ge"},
{"name"=>"ho'ge"},
{"name"=>"ka'kioe"},
{"name"=>"ka'kioe"},
{"name"=>"ka'kioe"},
{"name"=>"ka'kioe"},
{"name"=>"ka'kioe"},
{"name"=>"ka'kioe"},
{"name"=>"ka'kioe"},
{"name"=>"ka'kioe"}]
-
-
-
- -
-
-
select * from casket.tct
where age > 30
-
-
-
- -
-
-
[{"name"=>"falcon", "skill"=>"cook,blog", "lang"=>"ja", "age"=>"31"}]
-
-
-
- -
-
-
select * from casket.tct
where age = 30
-
-
-
- -
-
-
[{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"}]
-
-
-
- -
-
-
select * from casket.tct
where age = 30 and name = 'makio'
-
-
-
- -
-
-
[{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"}]
-
-
-
- -
-
-
select * from casket.tct
where age in (30, 31)
-
-
-
- -
-
-
[{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"falcon", "skill"=>"cook,blog", "lang"=>"ja", "age"=>"31"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"}]
-
-
-
- -
-
-
insert into casket.tct
(name, age) values ('ka''kioe', 25.3)
-
-
-
- -
-
-
true
-
-
-
- -
-
-
select * from casket.tct
where age >= 25.3
-
-
-
- -
-
-
[{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"falcon", "skill"=>"cook,blog", "lang"=>"ja", "age"=>"31"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"ka'kioe", "age"=>"25.3"}]
-
-
-
- -
-
-
update casket.tct
set name = '1262537068', time = 'Mon Jan 04 01:44:28 +0900 2010'
where age = 25.3
-
-
-
- -
-
-
true
-
-
-
- -
-
-
select * from casket.tct
where age = 25.3
-
-
-
- -
-
-
[{"name"=>"1262537068",
"time"=>"Mon Jan 04 01:44:28 +0900 2010",
"age"=>"25.3"}]
-
-
-
- -
-
-
delete from casket.tct
where age = 25.3
-
-
-
- -
-
-
true
-
-
-
- -
-
-
select * from casket.tct
where age = 25.3
-
-
-
- -
-
-
[]
-
-
-
- -
-
-
select * from casket.tct
-
-
-
- -
-
-
[{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"falcon", "skill"=>"cook,blog", "lang"=>"ja", "age"=>"31"},
{"name"=>"ozma", "skill"=>"song,dance", "lang"=>"en"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"mikio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"makio", "lang"=>"ja,en,c", "age"=>"30"},
{"name"=>"ho'ge", "age"=>"25"},
{"name"=>"ho'ge", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"},
{"name"=>"ka'kioe", "age"=>"25"}]