Ruby
Ruby Quickstart
Get started with the Ruby SDK
Here is the GitHub repository.
Quickstart
Prerequisites
Before you begin, make sure you have:
- A Fortress account
- Connection to your cloud account
- Your API token
- Your Organization ID
You can find your API token and Organization ID in the Fortress dashboard under the API Keys section.
Installation
Install the SDK using pip:
gem install fortress_sdk_ruby
Get Started
require 'fortress_sdk_ruby'
# Initialize the client
client = Fortress::Client.new(api_key, organization_id)
# Create a new tenant
client.create_tenant("tenant_name", "alias")
# Connect to the tenant
conn = client.connect_tenant("tenant_name")
conn.exec('CREATE TABLE users (id SERIAL PRIMARY KEY, name VARCHAR(50))')
conn.exec("INSERT INTO users (name) VALUES ('Alice')")
conn.exec('SELECT * FROM users') do |result|
result.each do |row|
print "User: #{row['name']}\n"
end
end
# Delete the tenant
client.delete_tenant("tenant_name")