I'm a fresher of rails and SQLite.
Here is my scenario:
I had sqlite3
installed on my Windows Vista machine.
A blog application code had also been implemented at c:\rails\blog
.
I brought up my command prompt and went directly to c:\rails\blog\db
.
I ran the command sqlite3
to enter the database console.
when I used the .databases
command, no database was listed out? Why?
What have I done wrong?
You probably didn't open the database itself
sqlite3 database.db
Remember, that in SQLite a database is just a file. As long as you don't open or attach one, there is no open one. On the other hand when you just open the database .databases
feels a kind of useless, because you know which one you just opened.
You must provide the database (path and) name to the sqlite3 command, e.g.,
Dev e$ sqlite3 my_test.db
SQLite version 3.7.7 2011-06-23 19:49:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .databases
seq name file
--- --------------- ----------------------------------------------------------
0 main /Users/e/Dev/my_test.db
sqlite>
When you run sqlite3
with no parameters, a temporary database is created, which will be destroyed as soon as the program exits. This is what you did.
To access the database, you need to specify the name of the file that holds the database.
$ sqlite3 my.db