venkat
venkat

Reputation: 836

Couldn't connect to sqlite3 database with rails application

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> 

Upvotes: 1

Views: 1439

Answers (2)

Angu
Angu

Reputation: 872

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

Upvotes: 0

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.

Upvotes: 2

Related Questions