2016-01-31 00:14:46 +00:00
|
|
|
class SQLite3::Connection < DB::Connection
|
2016-01-31 20:31:35 +00:00
|
|
|
def initialize(connection_string)
|
2016-01-31 00:14:46 +00:00
|
|
|
super
|
2016-01-31 20:31:35 +00:00
|
|
|
check LibSQLite3.open_v2(connection_string, out @db, (LibSQLite3::Flag::READWRITE | LibSQLite3::Flag::CREATE), nil)
|
2016-01-31 00:14:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def prepare(query)
|
|
|
|
Statement2.new(self, query)
|
|
|
|
end
|
|
|
|
|
|
|
|
def perform_close
|
|
|
|
LibSQLite3.close_v2(self)
|
|
|
|
end
|
|
|
|
|
2016-01-31 17:03:05 +00:00
|
|
|
def last_insert_id : Int64
|
|
|
|
LibSQLite3.last_insert_rowid(self)
|
|
|
|
end
|
|
|
|
|
2016-01-31 00:14:46 +00:00
|
|
|
def to_unsafe
|
|
|
|
@db
|
|
|
|
end
|
|
|
|
|
|
|
|
private def check(code)
|
|
|
|
raise Exception.new(self) unless code == 0
|
|
|
|
end
|
|
|
|
end
|