gpt4 book ai didi

ruby-on-rails - 如何在 Rails 中使用 rake 任务连接到 SQL Server?

转载 作者:太空宇宙 更新时间:2023-11-03 16:48:34 25 4
gpt4 key购买 nike

我尝试使用 ActiveRecord sqlserver 适配器连接到远程 SQL Server View :

@connection = ActiveRecord::Base.establish_connection(
:adapter => "sqlserver",
:dsn => "rms",
:hosts => "xxx.xxx.xx.xx",
:database => "V_MLS_ECOMM_STORE_SOH",
:ports => "1521",
:username => "xxxxxx",
:passwords => "xxxxxxx")

@connection.connected? 总是返回 false。

最佳答案

做这样的事情:

class LegacyTable < ActiveRecord::Base
establish_connection({
:adapter => "sqlserver",
:host => "host",
:username => "user",
:password => "pass",
:database => "dbname"
})

引用:https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/250

关于ruby-on-rails - 如何在 Rails 中使用 rake 任务连接到 SQL Server?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28403600/

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