Questions tagged [sequel]

Sequel is a database toolkit for the Ruby programming language that provides abstractions over many SQL RDBMS.

Sequel is a "Database Toolkit for Ruby" that:

  • ...provides thread safety, connection pooling and a concise DSL for constructing SQL queries and table schemas.

  • ...includes a comprehensive ORM layer for mapping records to Ruby objects and handling associated records.

  • ...supports advanced database features such as prepared statements, bound variables, stored procedures, savepoints, two-phase commit, transaction isolation, master/slave configurations, and database sharding.

  • ...has adapters for ADO, Amalgalite, DataObjects, DB2, DBI, Firebird, Informix, JDBC, MySQL, Mysql2, ODBC, OpenBase, Oracle, PostgreSQL, SQLite3, and Swift.

See the documentation for a list of guides, examples, tutorials, and other reference material.

Sequel is currently maintained and primarily developed by Jeremy Evans.

780 questions
0
votes
1 answer

How to insert values into SQLite and Sequel?

I'm trying to implement comments for my posts in a Sinatra blog. This is my db for comments and posts: DB.create_table :Posts do primary_key :id String :Title String :Content end DB.create_table :Comments do primary_key :id String…
uklp
  • 551
  • 1
  • 6
  • 14
0
votes
1 answer

Post.order method does not work with Sequel and Sinatra

I am trying to order my posts based on the created date ( newest to oldest ) so i do this : @posts = Post.order('created_at DESC') But the posts are not being affected by this. What can the problem be ?
uklp
  • 551
  • 1
  • 6
  • 14
0
votes
0 answers

How do I set up a unidirectional one-to-one association in Sequel?

For the tables in the following mock schema: Owner: id name business_id Business: id name I would like to have a unidirectional association from the owner to the business. I can't modify the schema to add a owner_id to the business table. How…
Elijah
  • 13,368
  • 10
  • 57
  • 89
0
votes
1 answer

Passing value from a dropdown box in Sqlite3 table with Sequel

I am trying to create a form where the user gives the title of an album and picks the artist name from a dropdown box. The problem is that I don't know how to take the value from the dropdown box.The new album is saved without any artist_id. I am…
magmike
  • 473
  • 1
  • 5
  • 18
0
votes
1 answer

boolean subquery in sequel

I am using the ruby sequel gem as my ORM on a project and I want to use the following query to load a sequel model: SELECT "subject", "addresses", "personal", "read_by", "folder", "created_at", "updated_at", "sent_at", "draft", --HOW DO I DO THIS IN…
dagda1
  • 26,856
  • 59
  • 237
  • 450
0
votes
1 answer

How to acquire Sequel database connection in Ruby library from Rails

I am building a gem to annotate Sequel models in Rails projects: https://github.com/kennym/annotate-sequel It is not working yet, because whenever I require a Rails model to parse its schema information I am getting the following error: No database…
Kenny Meyer
  • 7,849
  • 6
  • 45
  • 66
0
votes
1 answer

Sequel join: ".id" is returning the id of the the other table

I have a Ruby app which uses Ramaze and Sequel. I have the classes Tag and Tagging which have this relationship: class Tag < Sequel::Model one_to_many :taggings, :class => 'Thoth::Tagging' class Tagging < Sequel::Model(:taggings) many_to_one…
Max Williams
  • 32,435
  • 31
  • 130
  • 197
0
votes
1 answer

Sequel DB Connection PoolTimeout Error

I have been unable to determine what the cause of the following Sequel::PoolTimeout error is coming from in a Ruby script I have written: Sequel::PoolTimeout: Sequel::PoolTimeout hold at…
ylluminate
  • 12,102
  • 17
  • 78
  • 152
0
votes
1 answer

How can I count the count-values of Sequel::Dataset#group_and_count

I have a table and I count how often an element occurs. For this I can use Sequel::Dataset#group_and_count. But now I want to count this result. How can I do this? Example require 'sequel' Sequel.extension :pretty_table DB =…
knut
  • 27,320
  • 6
  • 84
  • 112
0
votes
2 answers

How can I make this sequel expression terser

I have the following expression: result = where( Sequel.like(Sequel.function(:lower, Sequel.join([:first_name, :last_name], ' ')), "%#{query.name.downcase}%") | Sequel.like(Sequel.function(:lower, :email), "%#{query.name.downcase}%") …
dagda1
  • 26,856
  • 59
  • 237
  • 450
0
votes
1 answer

How can I find the columns returned by a postgresql query without running the query itself?

Given a messy postgres query (e.g. with lots of subqueries) is there a way to figure out what columns will be returned by the query without running the query itself? If I understand correctly, Sequel's Dataset#columns method (Documentation) calls…
brahn
  • 12,096
  • 11
  • 39
  • 49
0
votes
1 answer

Do Sequel gem connections need to be manually closed when using Net::SSH::Gateway?

I am using the Sequel gem to connect to a database. The DB server is remote, though, so I have to log in over SSH first. My Ruby script is set up to, every five minutes, SSH in, ping the database, then close the SSH connection. (SSH is handled by…
jessepinho
  • 5,580
  • 1
  • 19
  • 19
0
votes
1 answer

Atomic username creation using SQL

I have a table 'users' that has, among others, the columns 'email' and 'username'. I want to make sure that when an account is created, no account(row) already exists with the same username or email. Currently, the program simply checks if the…
Shelvacu
  • 4,245
  • 25
  • 44
0
votes
1 answer

Ruby Sequel (SQlite3) 'SELECT' error

I'm using a ruby helper to extract data from an SQLite3 database using sequel ORM. Here is the code: #!/usr/bin/env ruby # encoding: UTF-8 require_relative 'greekdate' require 'sequel' module Pharmacy class Open def initialize …
patm
  • 1,420
  • 14
  • 19
0
votes
2 answers

How to get the current month with Sequel

I would like recover a list of entries for the current month with Sequel. I tried: Entry.where(:date >= Date.month).sum(:duration) or Entry.where(:date.like('%/06/2013')).sum(:duration) and other ways, but none of them seemed to work.