On Oct 19, 12:29 pm, Nate Wiger <[email protected]> wrote:
> So I tried:
>
>    Player.columns
>
> But unlike AR, which gives a structure that reflects the DB table
> (type, not null, precision, etc).  It's just a list of names.
>
> What can I use to inspect the table structure?  I tried

C:\>irb
irb(main):001:0> require 'sequel'
=> true

irb(main):002:0> DB = Sequel.sqlite
=> #<Sequel::SQLite::Database: "sqlite:/">

irb(main):003:0> DB << "CREATE TABLE cats ( id INTEGER PRIMARY KEY,
name TEXT NOT NULL, alias VARCHAR(50) )"
=> nil

irb(main):004:0> class Cat < Sequel::Model; end
=> nil

irb(main):005:0> Cat.db_schema
=> {:alias=>{:ruby_default=>nil, :type=>:string, :db_type=>"VARCHAR
(50)", :default=>nil, :allow_null=>true, :primary_key=>false}, :
ame=>
{:ruby_default=>nil, :type=>:string, :db_type=>"TEXT", :default=>nil, 
:allow_null=>false, :primary_key=>false}, :id=>
{:ruby_de
ault=>nil, :type=>:integer, :db_type=>"INTEGER", :default=>nil, 
:allow_null=>true, :primary_key=>true}}

irb(main):006:0> Cat.db_schema.keys
=> [:alias, :name, :id]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to