lib/picky/backends/sqlite/value.rb in picky-3.6.8 vs lib/picky/backends/sqlite/value.rb in picky-3.6.9
- old
+ new
@@ -4,26 +4,30 @@
class SQLite
class Value < Basic
+ def create_table
+ db.execute 'create table key_value (key varchar(255) PRIMARY KEY, value text);'
+ end
+
def []= key, value
- db.execute 'insert or replace into key_value (key, value) values (?,?)',
+ db.execute 'INSERT OR REPLACE INTO key_value (key, value) VALUES (?,?)',
key.to_s,
Yajl::Encoder.encode(value)
value
end
def [] key
- res = db.execute "select value from key_value where key = ? limit 1;", key.to_s
+ res = db.execute "SELECT value FROM key_value WHERE key = ? LIMIT 1;", key.to_s
return nil if res.empty?
Yajl::Parser.parse res.first.first
end
def delete key
- db.execute "delete from key_value where key = (?)", key.to_s
+ db.execute "DELETE FROM key_value WHERE key = (?)", key.to_s
end
end
end