gpt4 book ai didi

ruby - 运行cmd 时出错-“未找到带有'primary'的连接池”

转载 作者:行者123 更新时间:2023-12-03 18:43:06 28 4
gpt4 key购买 nike

我正在尝试为我的sinatra应用程序设置一个SQLite Db,但遇到了我无法弄清的错误。我查找了相关问题,但没有一个有帮助。

到目前为止,我已经运行bundle exec rake db:create_migration NAME=create_budget
这在我的数据库文件夹中创建了迁移。

但是,当我运行bundle exec rake db:migrate时,出现以下错误消息:

ActiveRecord::ConnectionNotEstablished: No connection pool with 'primary' found.

我正在按照教程https://learn.co/lessons/sinatra-activerecord-setup

database.yml-说明没有说要创建它,但是在研究错误时似乎不断出现。作为学习,这对我来说仍然是魔术,因此我不确定activerecord是否需要这样做。

 # SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

# 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:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000


迁移:使用 db:create_migration创建

# Database Migration
class CreateBudget < ActiveRecord::Migration[5.1]
def change
create_table :budget do |t|
t.string :description
t.string :amount
end
end
end


GemFile:

# frozen_string_literal: true

source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# gem "rails"

gem 'activerecord'
gem 'rake'
gem 'require_all'
gem 'sinatra'
gem 'sinatra-activerecord'
gem 'slim'
gem 'thin'

group :development do
gem 'pry'
gem 'shotgun'
gem 'sqlite3'
gem 'tux'
end


文件结构-不确定这是否有帮助

FilePath

最佳答案

bundle exec rake db:create:all

关于ruby - 运行cmd <rake db:migrate>时出错-“未找到带有'primary'的连接池”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46145748/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com