Visual Studio Code Can Do That? Working with SQLite
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.
[00:00:24] 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.
[00:00:49] 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.
[00:01:07] 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.
[00:01:34] 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.
[00:01:57] 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.
[00:02:19] 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.
[00:02:42] 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.
[00:02:58] 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.