mirror of
https://gitea.invidious.io/iv-org/shard-crystal-sqlite3.git
synced 2024-08-15 00:53:26 +00:00
881ef79893
Refactor flags, add option to dump from one database connection to another. Merge commit '135f33d9eac82c63a48b14942c8eff647c070410' into db # Conflicts: # spec/database_spec.cr # src/sqlite3/lib_sqlite3.cr # src/sqlite3/result_set.cr # src/sqlite3/statement.cr
24 lines
475 B
Crystal
24 lines
475 B
Crystal
require "spec"
|
|
require "../src/sqlite3"
|
|
|
|
include SQLite3
|
|
|
|
DB_FILENAME = "./test.db"
|
|
|
|
def with_db(&block : DB::Database ->)
|
|
File.delete(DB_FILENAME) rescue nil
|
|
DB.open "sqlite3:#{DB_FILENAME}", &block
|
|
ensure
|
|
File.delete(DB_FILENAME)
|
|
end
|
|
|
|
def with_db(name, &block : DB::Database ->)
|
|
File.delete(name) rescue nil
|
|
DB.open "sqlite3:#{name}", &block
|
|
ensure
|
|
File.delete(name)
|
|
end
|
|
|
|
def with_mem_db(&block : DB::Database ->)
|
|
DB.open "sqlite3://%3Amemory%3A", &block
|
|
end
|