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.

735 questions
6
votes
1 answer

Foreign Key constraint issues using sequel and database cleaner

I am running into issues using database cleaner with sequel and sqlite foreign key constraints. Specifically, I am using the :truncation strategy with Capybara integration tests. For the given sample schema: CREATE TABLE users(id INTEGER PRIMARY…
Nick Tomlin
  • 25,904
  • 10
  • 55
  • 84
6
votes
3 answers

Heroku Problem During Database Pull of Rails App: Mysql::Error MySQL server has gone away

Attempting to pull my database from Heroku gives an error partway through the process (below). Using: Snow Leopard; heroku-1.8.2; taps-0.2.26; rails-2.3.5; mysql-5.1.42. Database is smallish, as you can see from the error message. Heroku tech…
Rich Apodaca
  • 25,799
  • 16
  • 92
  • 115
6
votes
1 answer

Sequel generate migration

I see that the Sequel gem supports migrations here, but I don't see any type of generator documented. Does one exist; or should I be manually creating all of my migrations (or alternately creating my own task to generate migrations)?
bigtunacan
  • 4,333
  • 7
  • 32
  • 68
6
votes
2 answers

Ruby - Sequel Model to access multiple databases

I'm trying to use the Ruby Sequel::Model ORM functionality for a web service, in which every user's data is stored in a separate MySQL database. There may be thousands of users and thus databases. On every web request I want to construct the…
Peter Reay
  • 221
  • 4
  • 13
6
votes
2 answers

Does Ruby Sequel have an equivalent for the SQL "coalesce" function?

In SQL in order to avoid getting a NULL value, I can use the "coalesce" function to substitute it like so: SELECT COALESCE(some_column, 0) FROM some_table; But I can't find any way to do the same thing using Sequel.
6
votes
1 answer

Writing a complex case statement in Sequel?

I have a fairly complex case statement that works in MySQL: SELECT # rest of code omitted CASE WHEN code = 'a' THEN 'x' WHEN code IN ('m', 'n') THEN 'y' WHEN class IN ('p', 'q') AND amount < 0 THEN 'z' ELSE NULL END AS status FROM # rest of…
user1706938
  • 121
  • 7
6
votes
2 answers

The Sequel gem qualified query column name with table double underscores

Using the Sequel gem: employees = DB[:prm_master__employee.identifier] .join(:prm_master__employee_custom_fields.identifier, :employee => :employee) .where("termination_date >= ?","06/01/2012") .or("termination_date = NULL") .and("employee =…
lukemh
  • 4,674
  • 7
  • 26
  • 36
6
votes
1 answer

Sequel selecting too many columns

It seems like the default select for Sequel is "select *", which causes all kinds of problems when you add some joins. At the very least you end up with the wrong ids in your objects (because there will then be more than one "id" column returned).…
Phil Kulak
  • 5,882
  • 8
  • 40
  • 46
6
votes
2 answers

Sequel: How to use group and count

Simply put, how can I do this query using Sequel? select a.id, count(t.id) from albums a right join tracks t on t.album_id = a.id group by a.id
RooSoft
  • 1,359
  • 2
  • 15
  • 27
5
votes
2 answers

How to correctly load a gem extension in AWS Lambda

I'm having trouble working through a gem load error on AWS Lambda. { "errorMessage": "LoadError: libpq.so.5: cannot open shared object file: No such file or directory - /var/task/vendor/bundle/ruby/2.5.0/gems/pg-1.1.4/lib/pg_ext.so", …
1ijk
  • 1,267
  • 2
  • 14
  • 29
5
votes
2 answers

Associated object does not have a primary key

I still can't find a solution to fix an association factory issue when using Sequel. I have two models relying on one_to_many, which is the same as has_manyin Active Record, and many_to_one, which is the same as belongs_to in Active Record. Here are…
belgoros
  • 2,671
  • 3
  • 19
  • 49
5
votes
1 answer

How to disconnect an existing ruby sequel connection to a database?

I mean the one which was previously established as DB = Sequel.sqlite('my_blog.db') or DB = Sequel.connect('postgres://user:password@localhost/my_db') or DB = Sequel.postgres('my_db', :user => 'user', :password => 'password', :host =>…
mcmlxxxiii
  • 863
  • 1
  • 8
  • 21
5
votes
3 answers

What ORM to use in one process multiple db connections sinatra application?

Checked ActiveRecord, DataMapper, Sequel: some use globals (static variables) some require open db connection before loading source file with models. What ORM is better to use in sinatra application that uses different databases.
Andrey Yatsyk
  • 467
  • 2
  • 8
5
votes
3 answers

Ruby Sequel model to have validation for create and not update

How I can I avoid having validation for update while having it for create? For instance: I wish to have an image field to have presence validation on create. But want to avoid it in edit and assume the previous value in case of no change. Note: I am…
Jikku Jose
  • 16,638
  • 10
  • 35
  • 55
5
votes
2 answers

Boolean combinations of Sequel datasets

Given I have some dataset methods foo, bar and baz class User < Sequel::Model dataset_module do def foo # Some complicated dataset here where(:c => 42, :d => 23) end def bar # Even more complicated dataset here …
iblue
  • 26,668
  • 17
  • 81
  • 125
1 2
3
48 49