Last updated: Apr 6, 2024
Reading time·3 min

You can use an extension to open, view and query SQLite database files directly in Visual Studio Code.
To install the extension:
Ctrl + Shift + X on Windows or LinuxCommand + Shift + X on macOS
.db) file directly in VS CodeOnce you install the extension, you can open an SQLite file by:
Right-clicking on the file in Explorer.
Clicking on Open Database.




You can also right-click on a table to show it or run a query.

An alternative way to open the SQLite file is to:
Ctrl + Shift + P on Windows and Linux.Command + Shift + P on macOS.F1 to open the Command Palette.
Make sure to expand the SQLite Explorer menu in the left sidebar after you open the database.

To run a query, create a .sql file, for example, 001.sql and type a query.
The following code sample selects the first 10 rows from a table called
albums.
SELECT * FROM albums LIMIT 10;

To run the query:
Ctrl + Shift + P on Windows and Linux.Command + Shift + P on macOS.F1 to open the Command Palette.
Click on the SQLite: Run Query option.
You might get prompted to select your database.

Once you run the query a new tab that contains the results will open.

There is also a shortcut for running a query:
Ctrl + Shift + Q on Windows and Linux.Command + Shift + Q on macOS.The window that contains the results enables you to:

Once you are done working with the database, you can close it by:
Ctrl + Shift + P on Windows and Linux.Command + Shift + P on macOS.
I've also written an article on how to view and edit Binary files in VS Code.
You can learn more about the related topics by checking out the following tutorials: