我正在尝试配置一个在sqlite3中创建的数据库,用于我刚刚启动的Ruby on Rails项目。有人可以帮助我吗?因此,数据库已经在命令行中创建。
无法找到正确的命令来在命令行中使用!对此很陌生。
谢谢!
无法找到正确的命令来在命令行中使用!对此很陌生。
谢谢!
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
rails new your_app_name --database=sqlite3
这将直接在config/database.yml
下生成此配置:
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
config/database.yml
编辑设置:更改用户名/密码和数据库名称为您的Sqlite数据库的development环境,然后重新启动服务器 development:
adapter: sqlite3
encoding: utf8
database: [DB name]
username: [your username]
password: [your password]
host: [host name]
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
database.yml
文件(以及相应的模型类);在命令行中不需要使用任何命令。 - Amadan