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
2
votes
1 answer

How do I restrict the number of characters returned from a query using Sequel and Ruby?

My model is Article, and I want to display just a snippet of the body of the article, to give a preview of this particular article. How would I do that with Sequel? I thought it might be using limit, but that just limits the number of records…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
2
votes
2 answers

Consider scaling on Rails, would you write hand coded SQL? Use Sequel gem?

If I wanted to scale a Rails application by distributing its database on a different machine based on its authorization rules (location and user roles). So any resource attributed to that location would be sitting in a database dedicated to that…
Victor S
  • 5,098
  • 5
  • 44
  • 62
2
votes
2 answers

Need to retrieve top 3 vendors by total amount, per category - subcategory

I have this db table: http://sqlfiddle.com/#!9/e1dd38e/7 I am trying to query it so it goes thru each category, returning each subcategory's top 3 vendor's, ordered by their total of spend (sum(amount)), the vendors outside of the top 3 will be…
Brad
  • 12,054
  • 44
  • 118
  • 187
2
votes
1 answer

Tell sorbet about a Sequel Model's inheritance hierarchy

I'm trying to apply typing to a repo that uses the Sequel gem. It's got a non-standard Ruby syntax for a particular use case: initializing a model when a table name doesn't follow a convention Example: # This is necessary to get around #…
Eric Hu
  • 18,048
  • 9
  • 51
  • 67
2
votes
1 answer

"ArgumentError: string contains null byte" when connecting to Snowflake through ODBC from Ruby

I work on Mac M1 (Version 11.6 (20G165)), where installed the next software: https://sfc-repo.snowflakecomputing.com/odbc/mac64/latest/index.html iODBC-SDK-3.52.15-macOS11.dmg from…
2
votes
3 answers

Dynamic classes in Ruby, Class.new, unpacking Sequel::Model

I am new to ruby and trying to figure out how the class declaration below from Sequel gem works behind the scene. class Enumeration < Sequel::Model(DB[:enumerations]); end Upon quick investigation of Sequel gem's code, it seems to me that the…
has5aan
  • 23
  • 4
2
votes
2 answers

Ruby Gem Sequel - how to show only group by with count value > 1

With DB[:items].group_and_count(:name).all I get a list of names with the number of occurances. What do I need to do if I only want those names returned (incluing their count) that have a count of more than e.g. 2? In SQL I would do something like…
Ymox
  • 179
  • 12
2
votes
1 answer

How to run Postgres psql "slash" commands using Sequel

Using Sequel, is it possible to run PostgreSQL "slash" commands, such as \d, \dn or \copy table...? I tried using DB.run(‘\dn’) but I got a syntax error, because, presumably Sequel is trying to parse the SQL, or Postgres can’t understand the SQL,…
maniacalrobot
  • 2,413
  • 2
  • 18
  • 20
2
votes
2 answers

sequel trying to use postgresql instead of postgres as adapters

Had a simple heroku app with sequel and postgres. However, I got: % heroku rake db:migrate rake aborted! LoadError: no such file to load -- sequel/adapters/postgresql /app/.bundle/gems/ruby/1.9.1/gems/sequel-3.23.0/lib/sequel/core.rb:249:in…
Thomas
  • 21
  • 2
2
votes
1 answer

Sequel JsonSerializer conflicts with aliasing

In a Sinatra web application I am trying to get data from DB and convert them into object that is acceptable for UI (and finally to JSON). But there is some difference in names of attributes needed for UI and DB fields. So I have used Sequel query…
Andriy Tkach
  • 1,471
  • 2
  • 12
  • 19
2
votes
2 answers

Many to many relationship alias

I have a user model, and a tasks model. Task: class Task < Sequel::Model include ActiveModel::Serialization many_to_one :subject, polymorphic: true many_to_one :creator, key: :created_by, class: :User def_dataset_method(:sort_recent) do …
Avraam Mavridis
  • 8,698
  • 19
  • 79
  • 133
2
votes
1 answer

Pony and Sequel associations conflict?

I've run into an issue when using Pony and Sequel in a Sinatra application. Without Pony everything goes just fine, but just requiring Pony sequel's associations break. Here's my models for a blog: class Post < Sequel::Model one_to_many…
keepitterron
  • 1,052
  • 1
  • 8
  • 12
2
votes
1 answer

Add decimal values to excel via ADO-connection

I have problems to add decimals to an existing excel file via sequel/ado. I copy an existing excel file (template = 'minimal_template.xlsx) with two columns col1 and col2, then I insert two decimals. The result contains the data, but as strings: So…
knut
  • 27,320
  • 6
  • 84
  • 112
2
votes
1 answer

Matching list of values on multiple columns in Sequel

Given a table with a composite primary key, say a and b. If I have a list of pairs that I would like to query for, say, pairs = [[1, 1], [2, 2], [2, 1]] How can I filter using these in a dataset? The result in SQL would look like WHERE (a, b) IN…
Emil Ahlbäck
  • 6,085
  • 8
  • 39
  • 54
2
votes
1 answer

Ruby Sequel Subquery Happening Before Main Query

Can someone help me out with this? I need the following sql code translated to sequel: SELECT DISTINCT sales_leads.employee_person_id, (SELECT full_name from persons WHERE sales_leads.employee_person_id=persons.id), (SELECT COUNT…
harpocrates
  • 140
  • 7