0

**When I do "heroku db:push sqlite://mydatabase.db" I have a problem with Ruby + Sinatra + Sqlite3 + Heroku :

When i do : "heroku db:push sqlite://anotador.db"

Console log:

2013-01-21T12:37:11+00:00 app[web.1]: Errno::ENOENT - No such file or directory - /app/views/home.erb:
2013-01-21T12:37:11+00:00 app[web.1]:   /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:572:in `erb'

My anotador.rb :

require 'rubygems'  
require 'sinatra'  
require 'data_mapper'

DataMapper::setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/anotador.db")  
class Nota  
  include DataMapper::Resource  
  property :id, Serial  
  property :content, Text, :required => true  
  property :complete, Boolean, :required => true, :default => false  
  property :created_at, DateTime  
  property :updated_at, DateTime  
end  
DataMapper.finalize.auto_upgrade! 

My GemFile :

source :rubygems
gem 'sinatra'
gem 'data_mapper' 
gem 'rack-flash'
gem 'sinatra-redirect-with-flash'
gem 'builder'
gem 'dm-postgres-adapter', :group => :production
gem 'dm-sqlite-adapter', :group => :development
gem 'thin'

group :development, :test do
  gem 'sqlite3'
end
group :production do
  gem 'pg'
end

In command Line :

$ bundle
$ git init 
$ git add .
$ git commit -m "comentario" 
$ heroku create nombreAPP --stack cedar
$ git push heroku master 

$ heroku addons:add heroku-postgresql:dev
$ heroku pg:promote <DATABASE_URL>  
$ heroku db:push sqlite://anotador.db 

I know Heroku uses Postgres and SQLite not

But Heroku has the ability to move a database and use SQLite to Postgres exemplified in this link:

https://devcenter.heroku.com/articles/ruby # using-a-sql-database

I use sqlite3 in development and in production use Postgres

In GemFile :

group :development, :test do
  gem 'sqlite3'
end
group :production do
  gem 'pg'
end

This link have an example :

http://yamilurbina.com/post/4854924459/deploying-a-sinatra-datamapper-sqlite-app-to-heroku

Gabriel
  • 71
  • 4
  • 1
    Complete error stacktrace will be helpful – ch4nd4n Jan 21 '13 at 16:20
  • Excuse me for asking the obvious, but is there a file called `views/home.erb` when you run `git ls-files | grep home`? – ian Jan 21 '13 at 21:55
  • The error you’re showing looks like it comes from a normal request (`web.1`), not as a result of `db:push`, and is saying Sinatra can’t find the template file `home.erb` – nothing to do with the database. What message do you get immediately after running `db:push`? – matt Jan 22 '13 at 05:41
  • Duplicate of [Pushing Rails with SQLite3 to Heroku fails](http://stackoverflow.com/questions/3747002/pushing-rails-with-sqlite3-to-heroku-fails) –  May 25 '14 at 21:04
  • Or a better duplicate?: [Push an SQLite database to Heroku with taps?](http://stackoverflow.com/q/19817851/456814). –  May 25 '14 at 21:26

1 Answers1

1

As far as I know, you cannot use SQLite3 on Heroku. You can use Postgres or Mysql database instead.

So when you say

heroku db:push sqlite://mydatabase.db

You should not be doing that. It will not work because SQLite Gem is not available on Heroku. What is db:push? Is it some rake task? I suppose you would still need to specify that to Heroku.

Community
  • 1
  • 1
ch4nd4n
  • 4,110
  • 2
  • 21
  • 43
  • I think Ck- is right, AFAIK you won't be able to push a Sqlite database to Heroku, however you can pull a postgres db from Heroku into your local SQLite. I've never tried the other way around. – Jasdeep Singh Jan 21 '13 at 14:38
  • I know Heroku uses Postgres and SQL not But Heroku has the ability to move a database and use SQL to Postgres exemplified in this link: https://devcenter.heroku.com/articles/ruby # using-a-sql-database – Gabriel Jan 21 '13 at 16:00
  • Are you sure that the error message is specific to sqlite? It's cribbing for `/app/views/home.erb` can you verify if database has data? – ch4nd4n Jan 21 '13 at 16:23
  • No my database Prosgress is created but without data. I use sqlite3 in development and in production use Postgres. similar at example this link http://yamilurbina.com/post/4854924459/deploying-a-sinatra-datamapper-sqlite-app-to-heroku – Gabriel Jan 21 '13 at 16:30
  • +1, Ck is correct, and what does `db:push` do _exactly_? IMO you're asking for trouble by not using Postgres to develop as well, and it's very easy to get it set up now, either from the Heroku installer or the Postgres installer. – ian Jan 21 '13 at 21:50
  • @Gabriel you are referring to https://blog.heroku.com/archives/2009/3/18/push_and_pull_databases_to_and_from_heroku/ blog (2009). SO heroku db:push should push the data from local db to heroku. In case it is not can you verify if your local db has data? If it does, then is this heroku command still valid? – ch4nd4n Jan 22 '13 at 04:59
  • Finally I found what the problem was The views folder in my local repository was capitalized, listed as Views This is due to be working on Windows, while Heroku works in linux this came the error. Anyway thank you all for the help – Gabriel Jan 22 '13 at 23:51
  • See also [Push an SQLite database to Heroku with taps?](http://stackoverflow.com/q/19817851/456814). –  May 25 '14 at 21:28