Andrey Anischik
Andrey Anischik

Reputation: 11

How do I fix Sequel::DatabaseConnectionError while changing database

In the process of transition from sqlite to postgresql, I use this command taps server SQLite://db/development.sqlite3 jey 291298, but then the following problem appears. Maybe something is wrong with Gemfile. My version of rails is 5.1.6.

C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sequel-5.8.0/lib/sequel/adapters/sqlite.rb:105:in `initialize': SQLite3::CantOpenException: unable to open database file (Sequel::DatabaseConnectionError)
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sequel-5.8.0/lib/sequel/adapters/sqlite.rb:105:in `new'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sequel-5.8.0/lib/sequel/adapters/sqlite.rb:105:in `connect'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sequel-5.8.0/lib/sequel/connection_pool.rb:126:in `make_new'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sequel-5.8.0/lib/sequel/connection_pool/threaded.rb:192:in `assign_connection'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sequel-5.8.0/lib/sequel/connection_pool/threaded.rb:133:in `acquire'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sequel-5.8.0/lib/sequel/connection_pool/threaded.rb:90:in `hold'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sequel-5.8.0/lib/sequel/database/connecting.rb:264:in `synchronize'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sequel-5.8.0/lib/sequel/database/connecting.rb:279:in `test_connection'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sequel-5.8.0/lib/sequel/database/connecting.rb:58:in `connect'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sequel-5.8.0/lib/sequel/core.rb:116:in `connect'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/taps-0.3.24/lib/taps/db_session.rb:1:in `<top (required)>'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/taps-0.3.24/lib/taps/server.rb:4:in `<top (required)>'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/taps-0.3.24/lib/taps/cli.rb:61:in `server'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/taps-0.3.24/lib/taps/cli.rb:27:in `run'
    from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/taps-0.3.24/bin/taps:6:in `<top (required)>'
    from C:/RailsInstaller/Ruby2.3.3/bin/taps:22:in `load'
    from C:/RailsInstaller/Ruby2.3.3/bin/taps:22:in `<main>'

Gemfile

gem 'whenever', require: false
gem 'bcrypt', platforms: :ruby
gem 'cancan'
gem 'devise' 
gem 'rubocop', require: false
gem 'ransack'
gem 'kaminari'
gem 'nested_form'
gem 'simple_form'
gem 'state_machine'
gem 'ruby-graphviz', :require => 'graphviz'
gem 'stateful_enum'
gem 'hpricot'
gem 'highline'
gem "slim-rails"  
gem 'rails', '~> 5.1.6'
gem 'pg'
gem 'resque'
gem 'sinatra', '~> 2.0.0.beta2'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2' 
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bullet', group: 'development'

Some fragments from Gemfile.lock:

sequel (5.8.0)
sinatra (2.0.1)
  mustermann (~> 1.0)
  rack (~> 2.0)
  rack-protection (= 2.0.1)
  tilt (~> 2.0)

Upvotes: 0

Views: 920

Answers (1)

Jeremy Evans
Jeremy Evans

Reputation: 12139

With the error being SQLite3::CantOpenException: unable to open database file, the issue is that the ruby-sqlite3 driver cannot open the database file. Try running sqlite3 db/development.sqlite3 from the shell and see if you get the same or similar error. If so, it could be the file doesn't exist or the user does not have access to it. If not, it could be an issue in the ruby-sqlite3 driver.

Upvotes: 1

Related Questions