mirror of
https://gitea.invidious.io/iv-org/shard-crystal-sqlite3.git
synced 2024-08-15 00:53:26 +00:00
24 lines
463 B
Crystal
24 lines
463 B
Crystal
|
class SQLite3::Connection < DB::Connection
|
||
|
def initialize(options)
|
||
|
super
|
||
|
filename = options["database"]
|
||
|
check LibSQLite3.open_v2(filename, out @db, (LibSQLite3::Flag::READWRITE | LibSQLite3::Flag::CREATE), nil)
|
||
|
end
|
||
|
|
||
|
def prepare(query)
|
||
|
Statement2.new(self, query)
|
||
|
end
|
||
|
|
||
|
def perform_close
|
||
|
LibSQLite3.close_v2(self)
|
||
|
end
|
||
|
|
||
|
def to_unsafe
|
||
|
@db
|
||
|
end
|
||
|
|
||
|
private def check(code)
|
||
|
raise Exception.new(self) unless code == 0
|
||
|
end
|
||
|
end
|