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
0 answers

Can you use Sequel pagination with arbitrary queries?

I have a big horrible query that is built in lots of terrible steps (The problems with working with legacy databases.) which I would like to add pagination to. I had hoped to sidestep writing a custom result (I can't figure out how to get the total…
Mike H-R
  • 7,726
  • 5
  • 43
  • 65
0
votes
1 answer

How to define a class in Ruby when using Sequel?

I am using Ruby with Sinatra and Sequel. Now I am trying to create classes for my project, for example the class "User" which should contain "First Name" and "Lastname". When creating an instance of that class it should be possible to directly set…
Chris
  • 6,093
  • 11
  • 42
  • 55
0
votes
2 answers

How to display contents from a sequel database connection in the view file in Ruby?

I am trying to retrieve data from a PostgreSQL database with Sequel in Sinatra. DB = Sequel.connect('postgres://connection_data') items = DB[:items] Then I try to get an entry with a specific ID: get '/:id' do @item = items.filter(:id =>…
Chris
  • 6,093
  • 11
  • 42
  • 55
0
votes
1 answer

How do I handle whether or not to create a database in Sequel?

I am using Sequel with SQLite and want like to create the database from Ruby code if the SQLite database file does not exist yet. I could use the File class to look for the file but I am wondering if there is something in Sequel to handle this for…
Mark M
  • 1,807
  • 2
  • 21
  • 40
0
votes
1 answer

How to pass variable to DB.from in Sequel?

I'm just starting to use Sequel in Ruby, and like it alot. I want to pass a variable to the "from" method. So instead of calling a method like so: DB.from(:items) I'd like to call the method with a variable. For example: # both of the following…
Brad Parks
  • 66,836
  • 64
  • 257
  • 336
0
votes
1 answer

Different behaviour of column name between table and view

I have a table and a view based on the table: require 'sequel' db = Sequel.sqlite db.create_table(:t1){ String :f1 String :f2 } db.create_view(:v1, db[:t1].select(:f1)) If I create a dataset based on the table, the field name in the dataset an…
knut
  • 27,320
  • 6
  • 84
  • 112
0
votes
1 answer

Is there a way to untangle SQL log by connection in Sequel

I'm using the Sequel gem which works great. However I'm trying to debug a multithreading bug so I activated the log (at the Sequel level : .i.e using a Logger when creating the connection to the database). My problem is , all the SQL logs coming…
mb14
  • 22,276
  • 7
  • 60
  • 102
0
votes
1 answer

How to set the database to accept currency values?

I'm writing a Sinatra application with Sequel. For the first time, I'm trying to add a currency. After looking on-line I used Numeric as a value, of course goes without saying that I need a precision of decimal points. I know that in MySQL, Numeric…
patm
  • 1,420
  • 14
  • 19
0
votes
1 answer

Retrieving multiple datasets using the Sequel gem

I'm using the Sequel gem in the most basic manner possible - connecting to a local database and extracting the results. The one catch is that my code relies on me being able to execute multiple query statements at once (splitting them up is not an…
user2490003
  • 10,706
  • 17
  • 79
  • 155
0
votes
1 answer

Bundler.require(:default) fails in Rubinius

I have a very simple app, which i tried to run with Rubinius: Gemfile: source 'https://rubygems.org gem 'rake' gem 'tiny_tds' gem 'sequel' lib/database.rb: require "rubygems" require "bundler/setup" Bundler.require(:default) DB =…
Klaus
  • 903
  • 8
  • 19
0
votes
2 answers

Sequel Grep using variables as matcher

I'd like to do a query using the Sequel's Models object. I'd like the pattern to match certain variables value like so: Models::Show.grep(:name, %w'#{var1} #{var2}') But unfortunately, the Models.grep instance method seems not to be working this…
Francis.Beauchamp
  • 1,323
  • 15
  • 28
0
votes
0 answers

Ruby Testing: How do I use the same instance of Sequel in my tests?

I have a module defined along the following lines: module SomeModule DB = Sequel.connect("sqlite://database.db") end I'm using aruba (i.e. cucumber) in my tests, as this module is a CLI application. My problem is that when I add a record using…
Stoic
  • 10,536
  • 6
  • 41
  • 60
0
votes
1 answer

Ordering a Sequel dataset with subquery and limit with offset

I've run into an odd problem when trying to order a dataset based on the results of a subquery. It works fine until I try to add a limit with an offset, then I get an error saying that the sort column name is invalid. Here's a debugger session that…
bundacia
  • 1,036
  • 5
  • 13
0
votes
1 answer

SEQUEL - Subquery count syntax

Can anyone help me with the sequel syntax for the following the ruby orm sequel: SELECT *, (SELECT COUNT(*) FROM todos WHERE reference_email_id = "emails".id) todo_count FROM "emails" INNER JOIN "email_participants" ON…
dagda1
  • 26,856
  • 59
  • 237
  • 450
0
votes
1 answer

How to insert image into SQLite with Sequel and Sinatra?

I'm trying to insert images to each one of my blog posts using SQLite with Sequel and Sinatra. DB.create_table :posts do primary_key :id String :title String :content Datetime :created_at Datetime :updated_at foreign_key(:user_id, :users,…
uklp
  • 551
  • 1
  • 6
  • 14