- A quick demo showing how to use a Visual Studio Code Extension called SQLite made by alexcvzz to run queries against an SQLite database.🌟 Support the channe.
- SQL Management Studio or VS for SQL Server). The SQLite ecosystem contains tons of such client query applications. There is, for example, a SQLite / SQL Server Compact Toolbox Plug-in for Visual Studio that can be used to state SQL queries or review the current Data Definition of the database.
- Open Visual Studio, select new project, and, in Visual C#, select 'Console Application' and provide the name as SQLiteDemo.
Step 1: Install VS2017
I assume you know how to install visual studio 2017. so I ingore this step here.
Visual Studio; Visual Studio Code / Visual Studio for Mac; SQL Server Express LocalDB. LocalDB is a lightweight version of the SQL Server Express Database Engine that's targeted for program development. LocalDB starts on demand and runs in user mode, so there's no complex configuration.
Step 2: Download SQLite component
Download sqlite.h、sqlite.dll、sqlite.def files from SQLite official website.
- Download the source code. There is the sqlite.h file inside the source code.
2. Download the sqlite.dll and sqlite.def according to your system.(my system is x64)
Visual Studio Code Sqlite Tutorial
Step 3: Create a lib file
Find the lib.exe executable in Vistual Studio on your system.
In my case, the file path is “C:Program Files (x86)Microsoft Visual Studio2017CommunityVCToolsMSVC14.16.27023binHostx64x64lib.exe”.
Then, copy sqlite.def file to this folder and run the below command.
After doing that. You will get a *.lib file.
Note:
- If it fails to run the above command, you can try to copy the x64 folder outside of your Vistual Studio path and run the command again.
- If there is an error likes service error, you need to use administrator privilege to run the command.
Step 4: Add lib file to Vistual Studio
- Open Vistual Studio 2017 and create a project.
- Put sqlite.h and sqlite.dll files into project folder(the same path with source code)
- Browser to Project Properties->connector-> input->additional dependency and include *.lib(we created it in step 3) path.
Now, we can use SQLite in Vistual Studio 2017. Planner 5d desktop.
Step 5: Test
Below code is used to test if we can use SQLite in Vistual studio.
Note:
You can download a Database Browser to check the result or you can read the data from database after you have written it.
Related article:
Transcript from the 'Working with SQLite' Lesson
[00:00:00]
>> 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.
Visual Studio Open Sqlite Database
[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. Astar driver. 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.
New evernote. The new Evernote is coming soon to all your devices, so your notes will look and feel the same everywhere you go. Accomplish more with Evernote Collect everything that matters to you. In any format, on any device, at any time. Evernote connects with the productivity tools you already use, so you can work your way. Learn more → Document scanning. Back up important documents to all your devices, and keep the information—not the clutter. Learn more → Web Clipper. Save web pages (without the ads) and mark them up with arrows, highlights, and text to.
Sqlite In Visual Studio Code
[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.