SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    rails console error with sqlite 3

    Trying execute the code on page 103 and get the following error in the rails console:

    Loading development environment (Rails 2.1.0)
    >> class Story < ActiveRecord::Base; end
    => nil
    >> story = Story.new
    /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/errors.rb:94:in `check': malformed database schema - unrecognized token: "`" (SQLite3::AbortException)
    from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/statement.rb:71:in `initialize'
    from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:184:in `prepare'
    from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/database.rb:232:in `execute2'
    from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.1/lib/sqlite3/pragmas.rb:249:in `table_info'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:28:in `table_structure'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb:189:in `columns'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1145:in `columns'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2598:in `attributes_from_column_definition_without_lock'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/locking/optimistic.rb:55:in `attributes_from_column_definition'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2126:in `initialize'
    from (irb):2:in `irb_binding'
    from /usr/local/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding'
    from /usr/local/lib/ruby/1.8/irb/workspace.rb:52

    ############################
    my schema is:
    CREATE TABLE `stories` (
    `id` INTEGER PRIMARY KEY,
    `name` varchar(255) default NULL,
    `link` varchar(255) default NULL,
    `created_at` datetime DEFAULT NULL,
    `updated_at` datetime DEFAULT NULL
    )
    ############################

    error is:
    malformed database schema - unrecognized token: "`"

    What is wrong with the schema?

    Thanks in advance for you help.

    Stephen

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,044
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    Just a guess. Maybe if you used single quotes - ' - instead of backticks - ` -
    ??

  3. #3
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I'll give it a try.


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
  •