class Baza::Driver::Sqlite3Java
This class handels SQLite3-specific behaviour.
Attributes
mutex_statement_reader[R]
Public Class Methods
args()
click to toggle source
# File lib/baza/driver/sqlite3_java.rb, line 20 def self.args [{ label: "Path", name: "path" }] end
from_object(args)
click to toggle source
Helper to enable automatic registering of database using Baza::Db.from_object
# File lib/baza/driver/sqlite3_java.rb, line 8 def self.from_object(args) if args[:object].class.name == "Java::OrgSqlite::SQLiteConnection" return { type: :success, args: { type: :sqlite3_java, conn: args[:object] } } end end
new(db)
click to toggle source
Constructor. This should not be called manually.
Calls superclass method
Baza::JdbcDriver::new
# File lib/baza/driver/sqlite3_java.rb, line 28 def initialize(db) super @path = @db.opts[:path] if @db.opts[:path] @preload_results = true if @db.opts[:conn] @conn = @db.opts[:conn] else org.sqlite.JDBC reconnect end end
Public Instance Methods
escape(string)
click to toggle source
Escapes a string to be safe to used in a query.
# File lib/baza/driver/sqlite3_java.rb, line 50 def escape(string) # This code is taken directly from the documentation so we dont have to rely on the SQLite3::Database class. This way it can also be used with JRuby and IronRuby... # http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html string.to_s.gsub(/'/, "''") end
reconnect()
click to toggle source
# File lib/baza/driver/sqlite3_java.rb, line 42 def reconnect raise "No path was given." unless @path @stmt = nil @conn = java.sql.DriverManager.getConnection("jdbc:sqlite:#{@path}") end
transaction() { |db| ... }
click to toggle source
# File lib/baza/driver/sqlite3_java.rb, line 56 def transaction query_no_result_set("BEGIN TRANSACTION") begin yield @db query_no_result_set("COMMIT") rescue query_no_result_set("ROLLBACK") raise end end