DB::MariaDB GuidesGetting Started

Getting Started

This guide explains how to get started with the db-mariadb gem.

Installation

Add the gem to your project:

$ bundle add db-mariadb

Usage

Here is an example of the basic usage of the adapter:

require 'async'
require 'db/mariadb'

# Create an event loop:
Sync do
	# Create the adapter and connect to the database:
	adapter = DB::MariaDB::Adapter.new(database: 'test')
	connection = adapter.call
	
	# Execute the query:
	result = connection.send_query("SELECT VERSION()")
	
	# Get the results:
	pp connection.next_result.to_a
	# => [["10.4.13-MariaDB"]]
ensure
	# Return the connection to the client connection pool:
	connection.close
end