Michael M
Michael M

Reputation: 456

How do I acess/open/edit a .sqlite33 file?

I'm completely new to Ruby on Rails, have never worked on it, but I am supposed to take over somebody else's old project. He designed a webapp that logs into a website/server online, extracts data from it daily and performs calculations. However, the application has not been running for quite some time, so now when it tries to display statistics, the page crashes. It uses data from a 5 week period and currently only has data for 2 days.

I need to manually insert data for the missing weeks in order to get it up and running again, but the problem is I don't know how to find/access its database, nor how exactly to use Ruby on Rails. I found several files in the db directory of his project, however they were mostly .sqlite33 files or just 'files'. I downloaded sqlite precompiled binary for Windows and tried to use it, but not sure what to do. I also downloaded and tried using SQTView to open the files to change the tables, but I have had no luck.

How can I tell which file is the main database and how do I edit it? And what are .sqlite33 files? Thanks.

EDIT The application produces a TypeError in HomeController#index "nil can't be coerced into Float"

It links the error to a line in the code, but the only reason the error happens is because there is no data in the table for the time period that the variable in this line of code tries to use. That is why I want to manually update it with values.

I think that Sqliteman might do the trick and thank-you for explaining all of this to me. I just have to confirm it works after editing.

EDIT2 Okay, so I had a small revelation while experimenting on his app. It turned out that the page crashed because of empty values for full weeks. If I used the app to gather data for at least one day per week up until this week, then the app worked.

Is there a way I can populate all the missing days without having to manually click the days in its calendar because it takes a good 20-30 seconds for it to load?

Thank you very much for your help.

Upvotes: 0

Views: 120

Answers (1)

Idan Arye
Idan Arye

Reputation: 12603

A Rails application's database is defined in config/database.yml - though the database itself and the scheme are in the db folder. In database.yml you'll find three database configurations - development, test and production - so make sure to choose the right file.

I've never heard of .sqlite33 files, but to edit SQLite files manually I recommend SQLiteMan. But I don't recommend editing it manually.

What I do recommend is to check if you are running the app in development or production mode, as the two mods use different databases. Try to run it in the other mode.

If that doesn't work, try saving a copy of the database files, and running the commands:

bundle install
bundle exec rake assets:precompile
rake db:migrate
rake db:migrate RAILS_ENV="production"

(if you're using Linux, you might want to also run the first command with sudo)

Those commands make sure all the required gems are installed, that the precompiled assets are up to date, and that the database fits the schema. If you are running that application on the same machine and with the same database as the ones the other guy was using, than those commands shouldn't be necessary, but if you have moved the application to your own machine, or used an used an outdated db file, than those commands might fix the crash.

At any rate, if you tell us what error the application is producing we might be able to provide more assistance.

Upvotes: 1

Related Questions