伙计们,我正在尝试将我的应用程序连接到外部数据库来使用它。
我在文件末尾的database.yml中添加了配置。
external_db:
adapter: postgresql
encoding: utf8
database: db_name
host: https://hostdb.com.br/
username: user
password: pass
port: 5734
我为它创建了一个模型。
class ExternalDb < ApplicationRecord
self.abstract_class = true
establish_connection :external_db
end
好吧..在此之后我尝试与
进行简单的咨询x = ExternalDb.connection.execute("select * from PRODUTOS;")
我收到以下错误:
/home/rails/deploy/shared/vendor/bundle/ruby/3.0.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:87:in `rescue in new_client': could not translate host name "https://hostdb.com.br/" to address: Name or service not known (ActiveRecord::ConnectionNotEstablished)
/home/rails/deploy/shared/vendor/bundle/ruby/3.0.0/gems/pg-1.5.4/lib/pg/connection.rb:819:in `connect_start': could not translate host name "https://hostdb.com.br/" to address: Name or service not known (PG::ConnectionBad)