如何访问默认的Rails sqlite数据库? [英] How to access default Rails sqlite db?
问题描述
我想在使用Rails进行开发时查看我数据库中的数据(实际上这三个方面都是开发,测试和生产).我没有接触过配置,因此应该很容易,但是我找不到任何可用的信息.
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 be easy, but I was not able to find any usable info.
我不知道连接字符串可能是什么,或者在哪里输入连接字符串,因为Aptana(v.3)似乎缺少我从Eclipse知道的旧数据源资源管理器视图.有人可以指出我正确的方向吗?
I have no idea what the connection string could be or where to enter it, since Aptana (v.3) seems to lack the good old data source explorer view I know from Eclipse. Could someone point me into the right direction?
我正在linux上-Mint 12
I am working on linux - Mint 12
推荐答案
您忽略了所使用的操作系统.
You have neglected to mention the OS you are using.
一种方法是在终端中使用sqlite3
命令.
One way is to use the sqlite3
command in your terminal.
sqlite3 db/development.sqlite3
但是,对于诸如检查行之类的事情,您最好使用Rails控制台.
However, for things like inspecting your rows, you would be better using a rails console.
rails c
> User.all # Where user is your model.
注意::请勿直接通过sqlite3更改数据库架构,如果您来自其他Web堆栈背景,可能会习惯这种做法.这是因为下次运行迁移时,状态将与Rails期望的状态不同.
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.
这篇关于如何访问默认的Rails sqlite数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!