`
dn365
  • 浏览: 40004 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
最近访客 更多访客>>
社区版块
存档分类
最新评论

Rails with SQLite3

阅读更多
SQLite 是個輕量級的資料庫程式,因為我想在NB上寫Rails,但是又不想裝MySQL好重,第一個就想到SQLite。關於SQLite的中文介紹,可以參考 簡介SQLite 和 SQLite使用教學。基本上 sqlite 就是一隻 command-line 程式而已,再加上一個資料檔(即一個資料庫)。

要在Rails中使用,Windows 下首先去 SQLite 網站下載 執行檔 跟 DLL檔,即 sqlite3.exe 跟 sqlite3.dll,放到 C:/ruby/bin 下。FreeBSD的話,執行 /usr/ports/databases/sqlite3/make install。

接著安裝 sqlite for Ruby gem,執行 gem install sqlite3-ruby,Windows 下選擇 win32 ,FreeBSD下選 ruby 的版本。

最後設定 database.yml :

    development:
      adapter: sqlite3
      dbfile: db/dev.db

    test:
      adapter: sqlite3
      dbfile: db/test.db

    production:
      adapter: sqlite3
      dbfile: db/prod.db

然後執行你寫好的 Migrations 即可把資料庫建立出來。

如果你想要 SQLite 的 GUI 管理介面,試試 SQLite Database Browser,也是一個檔案而已,不需要安裝。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics