SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Chapter 4....Sqlite

    Hi,

    I am having trouble with a few things. This is all on page 102 of the book "Simply Rails 2".

    When the book says "SQLite console"...what is that? It tells us to enter the following command into the application directory: sqlite3 db/development.sqlite3

    What is the application directory? Is the book just telling us to type this into the Ruby console?

    Also, the book says to just copy and paste from the code archive, but the code in the archive is quite different from the code in the book.

    I have attached the response I get if I copy and paste the code from the archive.

    Being a beginner is very frustrating.....

    Thanks for the help and patience.
    Attached Images Attached Images

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,422
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    As long as everything installed OK, I think your problem is that you are not in the shovell application directory. Try changing to that directory. i.e.
    Code:
    ....\rails_apps>cd shovell
    ....\rails_apps\shovell>sqlite3 db/development.sqlite3

  3. #3
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried that and am getting a different error. See screenshot..thoughts?
    Attached Images Attached Images

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,422
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    As long as the config\database.yml file looks like
    Code:
    development:
     adapter: sqlite3
     database: db/development.sqlite3
     timeout: 5000
    test:
     adapter: sqlite3 database:
     db/test.sqlite3
     timeout: 5000
    production:
     adapter: sqlite3
     database: db/production.sqlite3
     timeout: 5000
    then
    Code:
    shovell>sqlite3 db/development
    specifies which database to use (i.e. "development") so there is no need to use a "USE [db name]"

    The book shows this query syntax
    Code:
    CREATE TABLE stories (
     "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
     "name" varchar(255) DEFAULT NULL,
     "link" varchar(255) DEFAULT NULL,
     "created_at" datetime DEFAULT NULL,
     "updated_at" datetime DEFAULT NULL
     );
    NOT
    Code:
    CREATE TABLE `stories` (
     `id` int(11) NOT NULL auto_increment,
     `name` varchar(255) default NULL,
     `link` varchar(255) default NULL,
     PRIMARY KEY (`id`)
     );
    which is what the archive's 02-create-stories-table.sql file has. This has caused a problem before. From the book's errata page http://www.sitepoint.com/books/rails2/errata.php (take a look so you won't get stung by other typos)
    p.102, 1st code listing

    The SQL code in the book is correct, the code in the code archive is incorrect.
    Last edited by Mittineague; Sep 25, 2008 at 08:48. Reason: reformatting yml code

  5. #5
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks! That worked. I appreciate your time.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •