浏览 4749 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2011-09-22
在网上Google了一翻, 很多解决方案都是围绕的ODBC, 这种方法配置麻烦, 在操作系统的不同版本之间也有细微的差异, 依赖的东西很多, 按着步骤配都会一路error.
Ruby官方推荐的解决方案是用ActiveRecord, 由于文档很少, 很少有人配置成功过, 这里给出详细步骤:
1. 安装brew工具, 类似于port 或者Linux的 apt-get https://github.com/mxcl/homebrew/wiki/installation
2. 安装freetds
brew edit freetds 执行后会用mate打开一个文本文件, 在里面的内容添加上一行 "--enable-msdblib",
def install args = ["--prefix=#{prefix}", "--with-tdsver=7.0", "--enable-msdblib", "--mandir=#{man}"] system "./configure", *args system 'make' system 'make install' end
现在可以安装了
brew install freetds 3. 安装tiny_tds
gem install tiny_tds
4. 连接sqlserver
创建一个配置文件database.yml:
development: adapter: sqlserver mode: dblib dataserver: my_sql_server database: my_database_name username: my_username password: xxxxx timeout: 5000
ruby code:
envHash = YAML.load(File.open("database.yml")) ActiveRecord::Base.establish_connection(envHash) 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2011-10-06
哇这也折腾出来了,人才
|
|
返回顶楼 | |
发表时间:2012-01-09
lz,
我按你的操作,结果还是error,ruby连接mssql已经纠结我好长时间,还请指导指导。 报错如下: ==> Downloading http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-0.91.tar.gz File already downloaded in /Library/Caches/Homebrew ==> ./configure --prefix=/usr/local/Cellar/freetds/0.91 --with-tdsver=8.0 --enable-msdblib --mandir=/usr/local/Cellar/freetds/0.91/share/man ==> make ==> make install Making install in include make[2]: Nothing to be done for `install-exec-am'. test -z "/usr/local/Cellar/freetds/0.91/include" || .././install-sh -c -d "/usr/local/Cellar/freetds/0.91/include" test -z "/usr/local/Cellar/freetds/0.91/include" || .././install-sh -c -d "/usr/local/Cellar/freetds/0.91/include" mkdir: /usr/local/Cellar/freetds/0.91/include: File exists make[2]: *** [install-includeHEADERS] Error 1 make[2]: *** Waiting for unfinished jobs.... /usr/bin/install -c -m 644 tds_sysdep_public.h '/usr/local/Cellar/freetds/0.91/include' make[1]: *** [install-am] Error 2 make: *** [install-recursive] Error 1 ==> Exit Status: 2 http://github.com/mxcl/homebrew/blob/master/Library/Formula/.rb#L ==> Environment /usr/bin/gcc HOMEBREW_VERSION: 0.8 HEAD: (none) HOMEBREW_PREFIX: /usr/local HOMEBREW_CELLAR: /usr/local/Cellar HOMEBREW_REPOSITORY: /usr/local HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew Hardware: quad-core 64-bit dunno OS X: 10.7 Kernel Architecture: x86_64 Ruby: 1.9.3-0 /usr/bin/ruby => /usr/local/bin/ruby Xcode: 4.2.1 GCC-4.0: N/A GCC-4.2: build 401 (5664 or newer recommended) LLVM: build 2336 MacPorts or Fink? false X11 installed? true ==> Build Flags CC: /usr/bin/cc => /usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 CXX: /usr/bin/c++ => /usr/llvm-gcc-4.2/bin/llvm-g++-4.2 LD: /usr/bin/cc => /usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 CFLAGS: -O3 -w -pipe CXXFLAGS: -O3 -w -pipe MAKEFLAGS: -j4 Error: Failed executing: make install Please report this bug: https://github.com/mxcl/homebrew/wiki/new-issue Also try: `brew doctor` to check your setup for common problems. `brew missing` to check installed packages for missing deps. |
|
返回顶楼 | |
发表时间:2012-05-04
用ruby操作sqlserver就是折腾人啊
|
|
返回顶楼 | |