How to access default Rails sqlite db?

前端 未结 8 1752
清酒与你
清酒与你 2020-12-13 03:37

I would like to view the data in my DB while developing with Rails (actually in all 3 of them development, test and production). I have not touched the configs, so it should

8条回答
  •  清歌不尽
    2020-12-13 04:18

    Rails 3 provides a generic command for accessing the correct database client and pass in the name of the correct database for your current environment. This command is rails dbconsole which can be shortened to rails db

    $ rails db
    SQLite version 3.6.12
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite> 
    

    This command does not offer much more than Gazler's answer and in fact his advice to use the console is good advice however the plus side for this method is that it will use the correct client if your DB is different in other environments.

提交回复
热议问题