💻

Setting up and Running SQLite on Visual Studio Code

Jun 22, 2024

Setting up and Running SQLite on Visual Studio Code

Introduction

  • Demonstration on how to set up and run SQLite on Visual Studio Code (VS Code).
  • Announced plans to create a comprehensive course on SQLite.
  • Encouraged to subscribe to the channel for updates and notifications.

Installing VS Code

  • Go to: code.visualstudio.com
  • Download depending on your operating system.
  • During installation, ensure you check all four options.

Setting up the Environment

  • Create a Folder: Name it (e.g., for-sqlite).
  • Open the Folder in VS Code: Right-click and select Open with Code.
  • Create Database File: Click on the plus button to create a new file, name it mydb.db (or any other name with .db extension).
  • Create SQL File: Click on the plus button to create a file for SQL queries, name it mysql.sql (with .sql extension).

Installing SQLite Extension in VS Code

  • Go to Extensions in VS Code.
  • Search for SQLite.
  • Install the SQLite extension by lxncv.
  • Reload VS Code: Open Command Palette (Shift + Ctrl + P), search for Reload, and select Developer: Reload Window.

Creating and Managing Tables and Records

Creating a Table

  • Open SQL File: mysql.sql
  • **Write Query: ** CREATE TABLE emp ( EMPLOYEE_ID INTEGER NOT NULL PRIMARY KEY, EMPLOYEE_NAME TEXT NOT NULL, EMAIL TEXT NOT NULL );
  • Run the Query:
    • Save file (Ctrl + S).
    • Open Command Palette, search for SQLite: Run Query.
    • Select Database (mydb.db).

Inserting Records

  • **Write Insert Statement: ** INSERT INTO emp (EMPLOYEE_ID, EMPLOYEE_NAME, EMAIL) VALUES (1, 'Sam', '[email protected]'); INSERT INTO emp (EMPLOYEE_ID, EMPLOYEE_NAME, EMAIL) VALUES (2, 'Tom', '[email protected]');
  • Run the Insert Queries: Save and follow the same process to run queries.

Reading Data

  • Write Select Statement: SELECT * FROM emp;
  • Run the Query: Save and run using Command Palette or right-click option.
  • View Results: The results will be displayed showing the inserted records.

Exploring Database in VS Code

  • Viewing Tables: Right-click on the database file in VS Code and explore various options like Open Database, New Query.
  • Viewing Table Schema: Right-click on the emp table and select Show Table. It displays columns - EMPLOYEE_ID, EMPLOYEE_NAME, EMAIL with their data types and constraints.

Conclusion

  • Encouragement to like, subscribe, and use coupon codes seriously.
  • Announcement of upcoming HTML course and instructions on how to get free access.