Skip to content

Commit

Permalink
update connection rdoc.
Browse files Browse the repository at this point in the history
  • Loading branch information
suketa committed Nov 17, 2024
1 parent 488d184 commit f620c5c
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions lib/duckdb/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module DuckDB
# con = db.connect
# con.query(sql)
class Connection
#
# executes sql with args.
# The first argument sql must be SQL string.
# The rest arguments are parameters of SQL string.
Expand All @@ -24,7 +23,6 @@ class Connection
#
# sql = 'SELECT * FROM users WHERE name = $name AND email = $email'
# dave = con.query(sql, name: 'Dave', email: 'dave@example.com')
#
def query(sql, *args, **kwargs)
return query_multi_sql(sql) if args.empty? && kwargs.empty?

Expand All @@ -45,7 +43,6 @@ def query_multi_sql(sql)
stmts&.destroy
end

#
# executes sql with args asynchronously.
# The first argument sql must be SQL string.
# The rest arguments are parameters of SQL string.
Expand All @@ -60,15 +57,13 @@ def query_multi_sql(sql)
# pending_result.execute_task while pending_result.state == :not_ready
# result = pending_result.execute_pending
# result.each.first
#
def async_query(sql, *args, **kwargs)
prepare(sql) do |stmt|
stmt.bind_args(*args, **kwargs)
stmt.pending_prepared
end
end

#
# executes sql with args asynchronously and provides streaming result.
# The first argument sql must be SQL string.
# The rest arguments are parameters of SQL string.
Expand All @@ -84,18 +79,15 @@ def async_query(sql, *args, **kwargs)
# pending_result.execute_task while pending_result.state == :not_ready
# result = pending_result.execute_pending
# result.each.first
#
def async_query_stream(sql, *args, **kwargs)
prepare(sql) do |stmt|
stmt.bind_args(*args, **kwargs)
stmt.pending_prepared_stream
end
end

#
# connects DuckDB database
# The first argument is DuckDB::Database object
#
def connect(db)
conn = _connect(db)
return conn unless block_given?
Expand All @@ -107,7 +99,6 @@ def connect(db)
end
end

#
# returns PreparedStatement object.
# The first argument is SQL string.
# If block is given, the block is executed with PreparedStatement object
Expand All @@ -127,17 +118,14 @@ def connect(db)
# stmt.bind_args(name: 'Dave', email: 'dave@example.com')
# stmt.execute
# end
#
def prepared_statement(str, &)
return PreparedStatement.new(self, str) unless block_given?

PreparedStatement.prepare(self, str, &)
end

#
# returns Appender object.
# The first argument is table name
#
def appender(table)
appender = create_appender(table)

Expand Down

0 comments on commit f620c5c

Please sign in to comment.