diff options
Diffstat (limited to 'src/guff/database.cr')
-rw-r--r-- | src/guff/database.cr | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/guff/database.cr b/src/guff/database.cr index 6e5906e..9811e80 100644 --- a/src/guff/database.cr +++ b/src/guff/database.cr @@ -15,18 +15,35 @@ module Guff pragma_foreign_keys: " PRAGMA foreign_keys = true ", + + pragma_query_only: " + PRAGMA query_only = true + ", } - def initialize(path) + def initialize( + path : String, + read_only : Bool = false, + @debug : Bool = false + ) super(path) @savepoint_id = 0_i64 + query(SQL[:pragma_foreign_keys]) + query(SQL[:pragma_query_only]) if read_only end - def initialize(path, &block : Database ->) + def initialize( + path : String, + read_only : Bool = false, + @debug : Bool = false, + &block : Database -> \ + ) super(path) @savepoint_id = 0_i64 + query(SQL[:pragma_foreign_keys]) + query(SQL[:pragma_query_only]) if read_only begin block.call(self) @@ -156,8 +173,9 @@ module Guff args : Array(String | Hash(String, String))? = nil, &block : ::SQLite3::ResultSet -> \ ) + STDERR.puts "DEBUG: sql = %s" % [sql] if @debug + # build statement - puts "sql = %s" % [sql] st = prepare(sql) # exec and close statement |