shard-crystal-db/src/db/db.cr

32 lines
705 B
Crystal
Raw Normal View History

2016-01-28 22:41:12 +00:00
module DB
TYPES = [String, Int32, Int64, Float32, Float64, Slice(UInt8)]
alias Any = String | Int32 | Int64 | Float32 | Float64 | Slice(UInt8)
# :nodoc:
2016-01-28 22:41:12 +00:00
def self.driver_class(name) # : Driver.class
@@drivers.not_nil![name]
end
def self.register_driver(name, klass : Driver.class)
@@drivers ||= {} of String => Driver.class
@@drivers.not_nil![name] = klass
end
def self.open(name, options)
Database.new(driver_class(name), options)
2016-01-28 22:41:12 +00:00
end
def self.open(name, options, &block)
open(name, options).tap do |db|
yield db
db.close
end
end
2016-01-28 22:41:12 +00:00
end
require "./database"
2016-01-28 22:41:12 +00:00
require "./driver"
require "./connection"
require "./statement"
require "./result_set"