Skip to content

Instantly share code, notes, and snippets.

@seki seki/sqlite3-util.rb
Created Aug 27, 2018

Embed
What would you like to do?
sqlite3-util.rb
class SQLite3::Database
def statement(s)
if @cache.nil?
@cache = Hash.new { |h, k| h[k] = self.prepare(k) }
end
@cache[s]
end
end
class SQLite3::Statement
def get_first_row(*bind_vars)
execute(*bind_vars).first
end
def get_first_value(*bind_vars)
execute(*bind_vars).each { |row| return row[0] }
nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.