SQLite3 与 JRuby 和 Sequel
SQLite3 with JRuby and Sequel
我需要在 Windows 上将 SQLite3 与 Jruby 和 Sequel gem 一起使用。
require 'sequel'
DB = Sequel.sqlite
我收到这个错误:
Sequel::AdapterNotFound: LoadError: no such file to load -- sqlite3
load_adapter at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/database/connecting.rb:93
adapter_class at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/database/connecting.rb:17
connect at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/database/connecting.rb:45
connect at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/core.rb:116
adapter_method at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/core.rb:394
block in sqlite at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/core.rb:401
<main> at test.rb:53
当我尝试安装 sqlite3 gem 时,它在构建本机扩展时失败了:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
current directory: C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sqlite3-1.3.1
3/ext/sqlite3
C:/jruby-9.1.13.0/bin/jruby.exe -r ./siteconf20181005-6576-1e4h1cf.rb extconf.rb
checking for sqlite3.h... RuntimeError: The compiler failed to generate an executable file.
You have to install development tools first.
try_do at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:456
try_cpp at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:587
block in find_header at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:1144
block in checking_for at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:942
block in postpone at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:350
open at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:320
block in postpone at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:350
open at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:320
postpone at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:346
checking_for at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:941
find_header at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:1143
<main> at extconf.rb:50
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/jruby-9.1.13.0/bin/jruby
--with-sqlite3-config
--without-sqlite3-config
--with-pkg-config
--without-pkg-config
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
C:/jruby-9.1.13.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/sql
ite3-1.3.13/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/s
qlite3-1.3.13 for inspection.
Results logged to C:/jruby-9.1.13.0/lib/ruby/gems/shared/extensions/universal-ja
va-1.8/2.3.0/sqlite3-1.3.13/gem_make.out
我已将 SQLite 库(sqlite3.dll、sqlite3.def)复制到 jruby/bin 文件夹中。
JRuby 官方页面建议使用 activerecord-jdbc-adapter,但我需要在内存中创建数据库,而不是连接到现有数据库。
我该怎么办?
我的环境:
Jruby 诉 9.1.13
Sequel 诉 5.9.0
Windows 服务器 2012 R2
您想使用 Sequel jdbc 适配器和 jdbc-sqlite3 gem:
require 'sequel'
DB = Sequel.connect("jdbc:sqlite::memory:")
FWIW,如果你想要一个带有 JRuby 的内存数据库,h2、hsqldb 和 derby 可能是更好的选择(Sequel 支持所有这些数据库)。
我需要在 Windows 上将 SQLite3 与 Jruby 和 Sequel gem 一起使用。
require 'sequel'
DB = Sequel.sqlite
我收到这个错误:
Sequel::AdapterNotFound: LoadError: no such file to load -- sqlite3
load_adapter at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/database/connecting.rb:93
adapter_class at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/database/connecting.rb:17
connect at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/database/connecting.rb:45
connect at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/core.rb:116
adapter_method at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/core.rb:394
block in sqlite at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/core.rb:401
<main> at test.rb:53
当我尝试安装 sqlite3 gem 时,它在构建本机扩展时失败了:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
current directory: C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sqlite3-1.3.1
3/ext/sqlite3
C:/jruby-9.1.13.0/bin/jruby.exe -r ./siteconf20181005-6576-1e4h1cf.rb extconf.rb
checking for sqlite3.h... RuntimeError: The compiler failed to generate an executable file.
You have to install development tools first.
try_do at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:456
try_cpp at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:587
block in find_header at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:1144
block in checking_for at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:942
block in postpone at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:350
open at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:320
block in postpone at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:350
open at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:320
postpone at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:346
checking_for at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:941
find_header at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:1143
<main> at extconf.rb:50
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/jruby-9.1.13.0/bin/jruby
--with-sqlite3-config
--without-sqlite3-config
--with-pkg-config
--without-pkg-config
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
C:/jruby-9.1.13.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/sql
ite3-1.3.13/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/s
qlite3-1.3.13 for inspection.
Results logged to C:/jruby-9.1.13.0/lib/ruby/gems/shared/extensions/universal-ja
va-1.8/2.3.0/sqlite3-1.3.13/gem_make.out
我已将 SQLite 库(sqlite3.dll、sqlite3.def)复制到 jruby/bin 文件夹中。
JRuby 官方页面建议使用 activerecord-jdbc-adapter,但我需要在内存中创建数据库,而不是连接到现有数据库。
我该怎么办?
我的环境:
Jruby 诉 9.1.13
Sequel 诉 5.9.0
Windows 服务器 2012 R2
您想使用 Sequel jdbc 适配器和 jdbc-sqlite3 gem:
require 'sequel'
DB = Sequel.connect("jdbc:sqlite::memory:")
FWIW,如果你想要一个带有 JRuby 的内存数据库,h2、hsqldb 和 derby 可能是更好的选择(Sequel 支持所有这些数据库)。