How to access default Rails sqlite db?

前端 未结 8 1721
清酒与你
清酒与你 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:07

    You have neglected to mention the OS you are using.

    One way is to use the sqlite3 command in your terminal.

    sqlite3 db/development.sqlite3
    

    However, for things like inspecting your rows, you would be better using a rails console.

    rails c
    > User.all # Where user is your model.
    

    NOTE: Do not change your DB schema directly through sqlite3, something you may be used to if you come from a different web stack background. This is because the next time you run the migrations, the state will be different to what rails expects.

提交回复
热议问题