April 7

0 comments

Viewing your SQLLite Data (Ruby on Rails beginners)

By Christopher Mendla

April 7, 2016


Last Updated on November 30, 2019 by Christopher G Mendla

When people are starting out with Ruby on Rails, one of the key elements is to be able to view the contents of the SQL file. For most people, they will use the SQLLite database. This is a limited implementation of SQL. The tables are all stored in one file which is located in /db of your Rails project.

When you go into production you will almost certainly transition to some version of an SQL server: Microsoft SQL Server, MySQL, Postgres or some other flavor of SQL. These will offer a lot more control as well as multi threading.

However, the beauty of Rails is that you can work in a development mode and then migrate your database when you go into production.

In order to view the SQL Tables and fields, you need to have a tool that will allow you to do so. There are a number of excellent free tools such as SQL Lite Browser.

https://github.com/sqlitebrowser/sqlitebrowser/releases

Once you download and install this tool, you can view your data. Some things to keep in mind are:

  • You should not make changes to the table structures via such a tool. That should be done within Rails via migrations.
  • You can make changes to the data. This is often helpful. However, you should (1) Remember to write the changes (2) Close the file in SQL Lite Browser before working again with your Rails application. Hint, you can go back to open and you should see your project database in the recent items.
  • To get to your database, look in the /db folder in your rails app. You need to know where your rails projects are stored and drill down from there. For example, if you were using the Aptana Studio IDE with the default workspace, they might be in C:UsersyouridDocumentsAptana Studio 3 Workspaceyourprojectdb. You should see a file called development.sqllite3.
Once you open up the file, you can see the structure and a tab to browse data.  You can now see the results of migrations and executing your application.
 

Christopher Mendla

About the author

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}