1

I installed sqlite3 gem with my rails application. I added sqlite3 to Gemfile and database.yml file and when I run rake db:create, rake db:migrate commands they are running fine but when I try to view it sqlite3 command prompt, i couldn't find my db. Please help me.

this is my database.yml file:

development:
  adapter: sqlite3
  database: emp_management
  pool: 5
  timeout: 5000

Gemfile:

gem 'sqlite3'

In sqlite command prompt:

raj@itadmin-HP-Pavilion-17-Notebook-PC:~/Desktop/Projects/empmanagement$ sqlite3
SQLite version 3.8.2 2013-12-06 14:53:30
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .databases
seq  name             file                                                      
---  ---------------  ----------------------------------------------------------
0    main                                                                       
sqlite> .tables
sqlite> 

2 Answers 2

2

Your sqlite databases should be in the project's "db" folder (directory). It looks like that's at

/Desktop/Projects/empmanagement/db

So either

$ sqlite3 db/development.sqlite3

or from the empmanagement directory

$ cd db
$ sqlite3 development.sqlite3

The database might not exist if you haven't run the rails server yet, or if you haven't run any migrations yet.

Sign up to request clarification or add additional context in comments.

2 Comments

Another option is to use the Rails dbconsole command: $ rails dbconsole. It will open the console of the DB referenced by the environment.
@Mike Sherrill 'Cat Recall': it's very useful for a starter like me. Thanks :)
0

You need an additional gem in your gemfile

 gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3' `

You can use these commands to install the gem and support libraries

 sudo apt-get install libsqlite3-dev`
 sudo gem install sqlite3-ruby` 
 sudo apt-get update

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.