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

How to get postgresql to work with sequel and jruby

require 'sequel' require 'jdbc/postgres' DB = Sequel.connect("jdbc:postgresql://user:pass@domain/database") DB.tables Returns: ....(bla bla bla stack trace bla bla bla).... Sequel::DatabaseConnectionError: Java::OrgPostgresqlUtil::PSQLException:…
Shelvacu
  • 4,245
  • 25
  • 44
4
votes
2 answers

How can I create SQL functions in Sequel?

I have a project with bunch of SQL scripts and I'm migrating the project into Sequel. In the old scripts I define a fair number of SQL functions to build up my queries. How should I create these functions so that I can access them from…
brahn
  • 12,096
  • 11
  • 39
  • 49
4
votes
1 answer

Returning model instances for a raw sql using Ruby Sequel

Is there a way to have Sequel return models instead of a hash for raw sql? class Post < Sequel::Model def self.recent db["some sql goes here"].all #would like models returned here instead end end Hope it makes sense.
Sunder
  • 1,445
  • 2
  • 12
  • 22
4
votes
2 answers

Clone Sequel Model

I have a Model representing a Pricing Table with lots of entries and i want to offer the possibility to create a new Pricing with values from an existing entry. Does anyone know how to do this, then Sequel is in use? I tried dup and clone but in…
jethroo
  • 2,086
  • 2
  • 18
  • 30
4
votes
1 answer

How can I store an image in a database using Ruby and Sequel?

I am using Ruby, or more specifically the Ramaze framework with the Sequel ORM. So please don't tell me about the Paperclip gem, as it is only compatible with ActiveRecord. With that in mind, how can I store an image in a database using Ruby and…
desbest
  • 4,746
  • 11
  • 51
  • 84
4
votes
2 answers

How do I connect to a postgres database with Sequel?

I was making a web app to deploy using Heroku.com when I realized that the only database type they support is PostgreSQL. Up until now, my app (powered by the Ruby gem Sinatra) accessed the database via the .Sqlite method for the Sequel gem. Here's…
Username
  • 3,463
  • 11
  • 68
  • 111
4
votes
1 answer

Clean association definitions with Ruby Sequel

I am using Jeremy Evan's Sequel to populate an (SQLite) database with data I scrape from web pages. The database involves a number of many_to_many relationships that I express with Associations. The associations are created in class definitions,…
ivan-k
  • 811
  • 1
  • 7
  • 20
4
votes
3 answers

How to check constraints in Sequel

How do I create a CHECK constraint to check for a range of possible values in Sequel. a Ruby ORM. All attempts seem to generate CHECK (1 = 0) as seen in the output logs. Here's the table I'm trying to model using Sequel's DSL: create table…
Sunder
  • 1,445
  • 2
  • 12
  • 22
4
votes
1 answer

Creating a table from a schema? Using Ruby Sequel gem

I can dump the current Database#schema, but I'd like to create a new table (in a different database) with that schema, but I dont see how this can be done? DB = Sequel.connect('sqlite:///database_from.db') schema = DB.schema :table # schema =>…
Ian Vaughan
  • 20,211
  • 13
  • 59
  • 79
3
votes
1 answer

How do I save a model recursively with Sequel?

I've been playing with Sequel and Sequel::Model. I created an Group with a many Items (one_to_many). I can do: Group.new << Item.new but not: Group.new.add_item(Item.new) nor: Item.new.group=Group.new. It complains about Group not having a…
mb14
  • 22,276
  • 7
  • 60
  • 102
3
votes
1 answer

How can I paginate across two tables using Sequel::Model?

For a change, I'm using a Ramaze, and therefore Sequel, based app instead of a Rails app. I have a model Tag which is many-to-many associated with :posts via a join table :taggings, and with :external_posts via a join table…
Max Williams
  • 32,435
  • 31
  • 130
  • 197
3
votes
0 answers

How to set an array contains value condition with Ruby Sequel?

I have this function that I need to modified to select from elements table the rows in which the column filters(array type) contain the feature_id param def get_categories_by_company_and_feature(company_id:,feature_id:) DB[:categories] …
3
votes
2 answers

How to call ActiveRecord validators as instance methods (ala Sequel)?

I've got a model that needs different validators depending on its current state. How should I go about calling ActiveRecord validators per instance? I'd like to reuse as much plumbing as possible, but I'm not sure how to continue. class Order <…
pithyless
  • 1,659
  • 2
  • 16
  • 31
3
votes
1 answer

Mulitiple row insert in Sequel skip if unique constrain occurs Ruby sequel

I know Dataset#multi_insert and Dataset#insert. does multi insert but is there an option available that can skip that particular insert when unique constrain check get activated
shaan
  • 482
  • 5
  • 25
3
votes
1 answer

How to nest a hash dataset when joining tables

I have a left outer join query and I would like to nest the result when I execute the query from the .all method. At the moment I am only able to return the result in a flat hash but I would like a nested hash so the join table name is the next…
Peter
  • 749
  • 10
  • 27