Problem with sqlite3


#1

Hi all,

I am relatively new to ruby and RoR. I created a simple rails proj named
foo by giving command
-> rails foo --database=sqlite3
It created a new rails proj… So in that I created a simple db class
named user by using the below command
-> ruby script/generate model user
so in db/migrate I got a file named 20090421211825_create_users.rb
created.
and in app/models : user.rb got created.
in user.rb… i have written like this

class User < ActiveRecord::Base
validate_uniqueness :userid
validate_presence_of :username
end

in 20090421211825_create_users.rb, its like this

class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.integer :userid
t.string :username, :limit => 32
t.timestamps
end
end

def self.down
drop_table :users
end
end

after I am done… I did rake db:migrate version=20090421211825

== CreateUsers: migrating

– create_table(:users)
-> 0.0014s
== CreateUsers: migrated (0.0018s)

I got schema.rb in db/migrate specifying the CREATE statement of the
USER…
now, I want to see whether my table exists in the db by just giving
-> sqlite3
SQLite version 3.4.0
Enter “.help” for instructions
sqlite> .tables
sqlite>

I am not getting my table… I don’t know whats wrong with that…Am I
looking into the correct place… Did I do correctly??

If anyone knows, please suggest me what to do …your response is
highly appreciated

Thanks,
Bhargavi.


#2

On Apr 21, 10:32 pm, Bhargavi V. removed_email_address@domain.invalid
wrote:

looking into the correct place… Did I do correctly??
You need to tell sqlite3 which database to look at - pass the path to
your database file as the first argument (eg sqlite3 db/
development.sqlite3 )

Fred


#3

Frederick C. wrote:

On Apr 21, 10:32�pm, Bhargavi V. removed_email_address@domain.invalid
wrote:

looking into the correct place… Did I do correctly??
You need to tell sqlite3 which database to look at - pass the path to
your database file as the first argument (eg sqlite3 db/
development.sqlite3 )

Fred

Hi Fred,

Thanks a lot!!! now I can see my tables… :slight_smile:

Thanks,
Bhargavi.