Check out a free preview of the full Visual Studio Code Can Do That? course

The "Working with SQLite" Lesson is part of the full, Visual Studio Code Can Do That? course featured in this preview video. Here's what you'd learn in this lesson:

Burke explains how to create a SQLite database, how to run a query, and how to update the database using the VS Code editor.


Transcript from the "Working with SQLite" Lesson

>> Burke Holland: So let's take a look at how we can use SQLite within VS Code. What I need to do first is, I want to open a terminal instance. And then from here, what we need to do is we need to create a data directory. And I've actually already got one, so I'm gonna say, remove the data directory.

We'll start from scratch. By the way, if you're on a Mac, and you didn't know, Cmd+K clears out the screen. Also, Ctrl+U clears off the current line. Cmd+K, Ctrl+U, those are magical commands if you're on Bash. So let's create a data directory. And then we're gonna move into that directory.

And you can see it appeared over here. I don't know if you saw but it's now in the Explorer. So I'm gonna say sqlite3. And because I've already included that, this command is just gonna run. And I'm gonna say lamp.db. And I'm gonna run this, and I'm gonna just hit databases to make sure that it's there.

There it is. And I'm gonna quit. If we do a list now, we see we have a lamp.db file. So we can now start interacting with this file from VS Code because it is a valid SQLite database. So let's do this. Cmd+Palette, Ctrl, Cmd+Shift+P, SQLite. And we're gonna say, open database.

And it's gonna wanna know which one. It automatically picked up this one, we'll select that. And now we have a SQLite Explorer over here. And inside is our database. And what we can do here is run a new query. And let's do some things here. So let's do, let's go back to the Explorer from my workspace.

Let's run some SQL here. So what I'm gonna do is create a table called colors. So we'll do this and we can run this. So we highlight it and we say, sqlite, run selected query. Boom. Okay, and now let's do, let's insert. In fact, let's grab both of these items.

Let's highlight just this line, run selected query, okay? And then let's highlight just this line, run selected query. There we go. All right, and now we're getting data back from SQLite. So you can see if you have a SQLite database in your project, you can use it directly from VS Code.

And you can interact with it without ever leaving your editor, which is pretty cool. I wanna do one more just to show you what's possible. There are other possible database options. The other one that we see quite a lot, quite a bit of use from is MySQL. A lot of people use MySQL.

I've given you an entire MySQL database as part of this dev container. I'm sorry in advance to the Internet here. So, whether or not you have MySQL installed, you will have to open this project.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now