完成所有迁移后,我将数据库从sqlite3
更改为mysql
。当我连接到Rails服务器时,发生错误。
我尝试了所有可以找到的解决方案,但是没有用。当我尝试使用rails server
运行服务器时,我得到:
> establish_connection': database configuration specifies nonexistent
> mysql2 adapter (ActiveRecord::AdapterNotFound)
我是Rails的新手,我不知道是什么原因造成的。可能是由于数据库移动或其他任何原因。
我在互联网上搜索了一天,但仍然没有解决办法。
为什么会发生这种情况,任何人都可以建议。我是否需要添加其他宝石。我正在使用sql5.5,并且也重新安装了它。我在卸载时删除了所有相关文件。
Database.yml文件:包含所有必需的内容
development:
adapter: mysql2
database: User_development
encoding: utf8
reconnect: false
host: 127.0.0.1
username: root
password:
pool: 5
timeout: 5000
test:
adapter: mysql2
database: User_test
encoding: utf8
reconnect: false
host: localhost
username: root
password:
pool: 5
timeout: 5000
socket: /tmp/mysql.sock
production:
adapter: mysql2
database: User_production
encoding: utf8
reconnect: false
host: localhost
username: root
password:
pool: 5
timeout: 5000
socket: /tmp/mysql.sock
GEM FILE: it contains all the required gems
source 'https://rubygems.org'
gem 'rails', '3.2.22'
gem 'rails_12factor'
gem 'test-unit'
gem 'bootstrap-sass', '2.1'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'yaml_db'
gem 'mysql2', '~> 0.3.0'
group :development, :test do
#gem 'sqlite3', '1.3.13'
gem 'rspec-rails', '2.11.0'
gem 'guard-rspec', '1.2.1'
end
group :development do
gem 'annotate', '2.5.0'
end
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.2'
group :test do
gem 'capybara', '1.1.2'
gem 'rb-fsevent', '0.9.1', :require => false
gem 'growl', '1.0.3'
gem 'factory_girl_rails', '4.1.0'
end
group :production do
gem 'pg', '0.12.1'
end
迁移后我还需要做其他事情吗?
答案 0 :(得分:1)
问题已解决。 gem install mysql adapter是这里的问题,您需要卸载它并删除它在config / initializers / abstract.rb文件中创建的文件
答案 1 :(得分:0)
我也面临这个问题。请按照下面
在envrionment.rb文件中添加以下行。
#import libraries
import schedule
import time
import alpaca_trade_api as tradeapi
import yfinance as yf
import pandas as pd
# Ask what stocks you want to check
pd = pd.DataFrame()
n = int(input("Enter the size of the list "))
print("\n")
numList = list(num for num in input("Enter the list numbers separated by space ").strip().split())[:n]
print("User List: ", numList)
# Get info for every stock chosen.
def get_data():
for ticker in numList:
ticker_yahoo = yf.Ticker(ticker)
data = ticker_yahoo.history(period = "1d", interval="1m")
data = (data.tail(1).iloc[0])
pd[ticker] = data
print(pd)
get_data()