I've been studying Ruby on Rails recently and use SQLite a lot.
I wanted to use the binary file **. sqlite3 ** that comes out there in VS Code, so I investigated how to do it.
It came when I was doing Chapter 6 of the Rails tutorial.
Target Rails tutorial → https://railstutorial.jp/chapters/modeling_users?version=5.1
Make a model ...
$ rails generate model User name:string email:string
After applying the migration ...
$ rails db:migrate
There was a file called db / development.sqlite3
.
However, this is a binary file and cannot be opened with VS Code. .. ..
Therefore, we will introduce an extension called "SQLite".
Try installing as usual from the VScode Marketplace.
It's easy to use.
Open the command palette and type "sql".
(How to open the command palette) Windows:Ctrl+Shift+P Mac:Command+Shift+P
Select "SQLite: Open Database" in the search results.
Since it will be a file selection, select the target file (this time select db / development.sqlite3
)
It looks like nothing is happening on the screen, but if you look closely at the Explorer tab, you will see an increase in the item "SQLITE EXPLORER", where each table and column is displayed.
Yeah, it feels like it.
If you want to see the data registered in the table, click "▶" next to each table name.
You could see it.
Now you can use SQLite on VS Code without opening any other tools!
Of course, even if you don't use VScode, there is a wonderful tool called DB Browser for SQLite, so you can choose which one to use.
Official site: https://sqlitebrowser.org/
Recommended Posts