Kuzu::

Connection class

Kùzu connection class

Public Instance Methods

execute( statement, **bound_variables, &block )

Executes the given statement (a Kuzu::PreparedStatement) after binding the given bound_variables to it.

# File lib/kuzu/connection.rb, line 34
def execute( statement, **bound_variables, &block )
        statement.bind( **bound_variables )
        return statement.execute
end
inspect()

Return a string representation of the receiver suitable for debugging.

# File lib/kuzu/connection.rb, line 41
def inspect
        details = " threads:%d" % [
                self.max_num_threads_for_exec,
        ]

        default = super
        return default.sub( />/, details + '>' )
end
max_num_threads_for_exec → integer

Returns the maximum number of threads of the connection to use for executing queries.

static VALUE
rkuzu_connection_max_num_threads_for_exec( VALUE self )
{
        rkuzu_connection *ptr = CHECK_CONNECTION( self );
        uint64_t count;

        if ( kuzu_connection_get_max_num_thread_for_exec( &ptr->conn, &count ) != KuzuSuccess ) {
                rb_raise( rkuzu_eError, "kuzu_connection_get_max_num_thread_for_exec failed" );
        }

        return ULONG2NUM( count );
}
max_num_threads_for_exec = integer

Sets the maximum number of threads of the connection to use for executing queries.

static VALUE
rkuzu_connection_max_num_threads_for_exec_eq( VALUE self, VALUE count )
{
        rkuzu_connection *ptr = CHECK_CONNECTION( self );
        uint64_t thread_count = NUM2ULONG( count );

        if ( kuzu_connection_set_max_num_thread_for_exec( &ptr->conn, thread_count ) != KuzuSuccess ) {
                rb_raise( rkuzu_eError, "kuzu_connection_set_max_num_thread_for_exec failed" );
        }

        return Qtrue;
}
prepare( query_string )

Create a new Kuzu::PreparedStatement for the specified query_string.

# File lib/kuzu/connection.rb, line 27
def prepare( query_string )
        return Kuzu::PreparedStatement.new( self, query_string )
end
query( query_string, &block )

Execute the given query_string via the connection and return the Kuzu::Result. If a block is given, the result will instead be yielded to it, finished when it returns, and the return value of the block will be returned instead.

# File lib/kuzu/connection.rb, line 20
def query( query_string, &block )
        result = self._query( query_string )
        return Kuzu::Result.wrap_block_result( result, &block )
end
query!( query_string )

Execute the given query_string and return true if the query was successful.

static VALUE
rkuzu_connection_query_bang( VALUE self, VALUE query )
{
        kuzu_query_result result = rkuzu_connection_do_query( self, query );
        return kuzu_query_result_is_success( &result ) ? Qtrue : Qfalse;
}
Also aliased as: run
query_timeout = integer

Sets query timeout value in milliseconds for the connection.

static VALUE
rkuzu_connection_query_timeout_eq( VALUE self, VALUE timeout )
{
        rkuzu_connection *ptr = CHECK_CONNECTION( self );
        uint64_t timeout_in_ms = NUM2ULONG( timeout );

        if ( kuzu_connection_set_query_timeout( &ptr->conn, timeout_in_ms ) != KuzuSuccess ) {
                rb_raise( rkuzu_eError, "kuzu_connection_set_query_timeout failed" );
        }

        return Qtrue;
}
run(p1)

Execute the given query_string and return true if the query was successful.

Alias for: query!