Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataMapper SQLite Error when creating new database

I am new to Sinatra and I am trying to make a database using SQLite3 and Datamapper. I installed both gems and also the adaptor and then tried to execute this code in a file:

#config
require 'sinatra'
require 'sinatra/contrib' if development?
require 'data_mapper'

DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/recall.db")  
DataMapper.finalize.auto_upgrade!  

The command line gave me this error when I executed the file:

C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require':126: The specified module could not be found.   - 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/do_sqlite3-0.10.10-x86-mingw32/lib/do_sqlite3/1.9/do_sqlite3.so (LoadError)

and then a lot of other things which went wrong because of these errors. I tried reinstalling many of the gems but nothing seems to have worked.

EDIT: The full error code was this:

C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require':126: The specified module could not be found.   - C:/Ruby193/lib/ruby/gems/1.9.1/gems/do_sqlite3-0.10.10-x86-mingw32/lib/do_sqlite3/1.9/do_sqlite3.so (LoadError)
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/backports-2.6.5/lib/backports/tools.rb:314:in `require_with_backports'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/do_sqlite3-0.10.10-x86-mingw32/lib/do_sqlite3.rb:31:in `rescue in <top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/do_sqlite3-0.10.10-x86-mingw32/lib/do_sqlite3.rb:26:in `<top (required)>'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/backports-2.6.5/lib/backports/tools.rb:314:in `require_with_backports'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dm-sqlite-adapter-1.2.0/lib/dm-sqlite-adapter/adapter.rb:1:in `<top (required)>'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/backports-2.6.5/lib/backports/tools.rb:314:in `require_with_backports'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dm-sqlite-adapter-1.2.0/lib/dm-sqlite-adapter.rb:1:in `<top (required)>'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/backports-2.6.5/lib/backports/tools.rb:314:in `require_with_backports'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/adapters.rb:163:in `load_adapter'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/adapters.rb:133:in `adapter_class'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/adapters.rb:13:in `new'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core.rb:230:in `setup'
from test.rb:7:in `<main>'
like image 812
Amja Avatar asked Dec 22 '12 12:12

Amja


2 Answers

I had this problem, using ruby 1.9.3 on windows - fixed it by downloading the sqlite3.dll from http://www.sqlite.org/download.html and putting it in C:\Ruby193\bin

like image 69
genegc Avatar answered Nov 04 '22 21:11

genegc


Try adding:

require 'dm-sqlite-adapter'

If that doesn't fix things, you could also try changing

DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/recall.db")

to

DataMapper.setup(:default, 'sqlite:recall.db')

and see if that fixes it. I really don't know the cause, but doing the above (single quotes, no "3", and no path) fixed an error I was receiving when trying a particular setup.

like image 2
Gus Shortz Avatar answered Nov 04 '22 21:11

Gus Shortz