lib/duckdb/database.rb in duckdb-1.1.3.0 vs lib/duckdb/database.rb in duckdb-1.1.3.1
- old
+ new
@@ -18,17 +18,15 @@
#
# result = con.query('SELECT * from users')
# result.each do |row|
# p row
# end
- #
class Database
private_class_method :_open
private_class_method :_open_ext
class << self
- ##
# Opens database.
# The first argument is DuckDB database file path to open.
# If there is no argument, the method opens DuckDB database in memory.
# The method yields block if block is given.
#
@@ -38,11 +36,10 @@
#
# DuckDB::Database.open do |db|
# con = db.connect
# con.query('CREATE TABLE users (id INTEGER, name VARCHAR(30))')
# end
- #
def open(dbpath = nil, config = nil)
db = _db_open(dbpath, config)
return db unless block_given?
begin
@@ -52,20 +49,19 @@
end
end
private
- def _db_open(dbpath, config)
+ def _db_open(dbpath, config) # :nodoc:
if config
_open_ext(dbpath, config)
else
_open(dbpath)
end
end
end
- ##
# connects database.
#
# The method yields block and disconnects the database if block given
#
# db = DuckDB::Database.open
@@ -73,10 +69,9 @@
# con = db.connect # => DuckDB::Connection
#
# db.connect do |con|
# con.query('CREATE TABLE users (id INTEGER, name VARCHAR(30))')
# end
- #
def connect
conn = _connect
return conn unless block_given?
begin