Help on SQLITE3-ruby (1.2.3) Windows problem

J

jhs408

Your Help please:

I have installed sqlite3 in directory : c:\tools\sqlite3\
and performed gem install : gem install sqlite3-ruby-1.2.3-
mswin32.gem

test2.rb program:
#--------------------------------------------------------------
require 'rubygems'
require 'sqlite3/database'
require 'sqlite3'

File.delete "test.db" rescue nil

db = SQLite3::Database.new( "test.db" )
sql = <<SQL
create table the_table (
a varchar2(30),
b varchar2(30)
);

insert into the_table values ( 'one', 'two' );
insert into the_table values ( 'three', 'four' );
insert into the_table values ( 'five', 'six' );
SQL

db.execute_batch( sql )


db.execute( "select * from the_table" ) do |row|
p row
end
#-----------------------------------------------------------

** upon executing the program: ruby test2.rb

it can not file sqlite3.dll

But when I move aa copy of sqlite3.dll into the same directory as
test2.rb
then everything runs OK.

Question: How do I condition sqlite3-ruby to load the sqlite3.dll
from the directory c:\tools\sqlite3?

Thanks for your assistance,
John
 
B

Bosko Ivanisevic

Your Help please:

I have installed sqlite3 in directory :  c:\tools\sqlite3\
and performed gem install :  gem install sqlite3-ruby-1.2.3-
mswin32.gem

test2.rb  program:
#--------------------------------------------------------------
require 'rubygems'
require 'sqlite3/database'
  require 'sqlite3'

  File.delete "test.db" rescue nil

   db = SQLite3::Database.new( "test.db" )
 sql = <<SQL
     create table the_table (
       a varchar2(30),
       b varchar2(30)
     );

     insert into the_table values ( 'one', 'two' );
     insert into the_table values ( 'three', 'four' );
     insert into the_table values ( 'five', 'six' );
SQL

   db.execute_batch( sql )

db.execute( "select * from the_table" ) do |row|
    p row
  end
#-----------------------------------------------------------

** upon executing the program:  ruby test2.rb

   it can not file sqlite3.dll

But when I move aa copy of sqlite3.dll into the same directory as
test2.rb
then everything runs OK.

Question:  How do I condition sqlite3-ruby to load the sqlite3.dll
from the directory c:\tools\sqlite3?

Thanks for your assistance,
John

Put c:\tools\sqlite3 in the PATH environment variable.
 
L

Luis Lavena

Your Help please:

I have installed sqlite3 in directory :  c:\tools\sqlite3\
and performed gem install :  gem install sqlite3-ruby-1.2.3-
mswin32.gem

test2.rb  program:
#--------------------------------------------------------------
require 'rubygems'
require 'sqlite3/database'
  require 'sqlite3'

  File.delete "test.db" rescue nil

   db = SQLite3::Database.new( "test.db" )
 sql = <<SQL
     create table the_table (
       a varchar2(30),
       b varchar2(30)
     );

     insert into the_table values ( 'one', 'two' );
     insert into the_table values ( 'three', 'four' );
     insert into the_table values ( 'five', 'six' );
SQL

   db.execute_batch( sql )

db.execute( "select * from the_table" ) do |row|
    p row
  end
#-----------------------------------------------------------

** upon executing the program:  ruby test2.rb

   it can not file sqlite3.dll

But when I move aa copy of sqlite3.dll into the same directory as
test2.rb
then everything runs OK.

Question:  How do I condition sqlite3-ruby to load the sqlite3.dll
from the directory c:\tools\sqlite3?

Thanks for your assistance,
John

For Windows to load shared libraries (.dll) needs to find those in any
of the directories of PATH, including the directory where the
executable (ruby.exe) is located.

Now, this is similar to LD_LIBRARY_PATH on *nix, but playing with it
is considered harmful [1]

sqlite3-ruby is built on Windows against the binary version of SQLite,
which requires the dll to be found in the PATH.

One alternative is add c:\tools\sqlite3 to the PATH:

SET PATH=%PATH%;C:\tools\sqlite3

The other alternative is put sqlite3.dll binary in the Ruby folder.

[1] http://linuxmafia.com/faq/Admin/ld-lib-path.html

HTH,
 
J

Jeremy Hinegardner

Your Help please:

I have installed sqlite3 in directory : ?c:\tools\sqlite3\
and performed gem install : ?gem install sqlite3-ruby-1.2.3-
mswin32.gem

test2.rb ?program:
#--------------------------------------------------------------
require 'rubygems'
require 'sqlite3/database'
? require 'sqlite3'

? File.delete "test.db" rescue nil

? ?db = SQLite3::Database.new( "test.db" )
?sql = <<SQL
? ? ?create table the_table (
? ? ? ?a varchar2(30),
? ? ? ?b varchar2(30)
? ? ?);

? ? ?insert into the_table values ( 'one', 'two' );
? ? ?insert into the_table values ( 'three', 'four' );
? ? ?insert into the_table values ( 'five', 'six' );
SQL

? ?db.execute_batch( sql )

db.execute( "select * from the_table" ) do |row|
? ? p row
? end
#-----------------------------------------------------------

** upon executing the program: ?ruby test2.rb

? ?it can not file sqlite3.dll

But when I move aa copy of sqlite3.dll into the same directory as
test2.rb
then everything runs OK.

Question: ?How do I condition sqlite3-ruby to load the sqlite3.dll
from the directory c:\tools\sqlite3?

Thanks for your assistance,
John

For Windows to load shared libraries (.dll) needs to find those in any
of the directories of PATH, including the directory where the
executable (ruby.exe) is located.

Now, this is similar to LD_LIBRARY_PATH on *nix, but playing with it
is considered harmful [1]

sqlite3-ruby is built on Windows against the binary version of SQLite,
which requires the dll to be found in the PATH.

One alternative is add c:\tools\sqlite3 to the PATH:

SET PATH=%PATH%;C:\tools\sqlite3

The other alternative is put sqlite3.dll binary in the Ruby folder.

Another option is to use Amalgalite which embeds SQLite in the ruby extension,
no need to download the sqlite3.dll separately. If you are using sqlite
directly then that is a good option. if you need to use ActiveRecord or Sequel
or something like that, the drivers for ORM's do not exist, yet.

enjoy,

-jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top