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
6
votes
3 answers

heroku db:pull not working

heroku db:pull postgresql://root:@localhost/db_name After this command display this message /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.1/lib/restclient/abstract_response.rb:50: warning: parenthesize argument(s) for future version Loaded Taps…
ritesh
  • 61
  • 1
  • 2
6
votes
2 answers

How to pull Heroku data into a local SQLite3 database

I'm trying to make a local backup of the data from my Rails application, which is deployed to Heroku, and running into problems. I followed the taps instructions and installed Taps. I get two types of errors. I created a SQLite DB locally and tried…
kateray
  • 2,066
  • 4
  • 18
  • 23
6
votes
3 answers

Mysql / Ruby Sequel last insert ID value, what method?

I just want to get the last_insert_id() using Ruby's Sequel: insertret = @con.run("INSERT INTO `wv_persons` ( `id` ) VALUES ( NULL )") pp insertret.inspect # returns "nil", expected that.. last_insert_id = @con.run("SELECT LAST_INSERT_ID() AS…
sougonde
  • 3,438
  • 3
  • 26
  • 35
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
  • 28,402
  • 11
  • 61
  • 90
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
  • 28,316
  • 16
  • 103
  • 129
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
  • 231
  • 5
  • 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
2 answers

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
  • 131
  • 1
  • 9
6
votes
3 answers

Using Sequel, can I create UPDATE statements with a FROM clause

Using Sequel I'd like to create an UPDATE statement like the following (from Postgres docs) UPDATE employees SET sales_count = sales_count + 1 FROM accounts WHERE accounts.name = 'Acme Corporation' AND employees.id =…
brahn
  • 12,096
  • 11
  • 39
  • 49
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
  • 5,043
  • 7
  • 30
  • 38
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
  • 6,960
  • 8
  • 45
  • 50
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,481
  • 2
  • 17
  • 32
5
votes
2 answers

Nesting a Ruby hash

I have a method that selects all the rows from my table like this: smtp_status_raw = my_table.select(:message, :is_valid, :hostname).map { |h| h.values } This returns an array that's like this: [{:message=>"blah", :is_valid=>true, :hostname=>"1"},…
theGreenCabbage
  • 5,197
  • 19
  • 79
  • 169
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
  • 3,590
  • 7
  • 38
  • 76
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
  • 913
  • 1
  • 9
  • 21
1 2
3
51 52