2

I'm looking to build an application using the Padrino Framework with Sequel as my ORM. The problem is that I need to interface with an existing database which was created using singularly named tables. Rather than renaming the SQL tables (as other applications also use this database), would I be able to have padrino use a singular name for tables (such as "Entry" instead of "Entries")?

Thanks for your time and assistance.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
kkirsche
  • 1,217
  • 2
  • 15
  • 38

1 Answers1

2

You can define a Sequel model on a table with a singular/arbitrary name like this:

class Entry < Sequel::Model(:entry); end

Tried this myself in Padrino with an "Entry" table (PostgreSQL) and it works:-

$ padrino c

> e = Entry.new
 => #<Entry @values={}> 
> e.save
 => #<Entry @values={:id=>1}> 
> Entry.count
 => 1 

Inspiration from this question on the Sequel-Talk Google Group

MatzFan
  • 877
  • 8
  • 17