How to run SQLite on Windows?
To run SQLite on Windows, follow these steps:
1. Download SQLite
- Go to the official SQLite website:
🔗 https://www.sqlite.org/download.html - Scroll down to the "Precompiled Binaries for Windows" section.
- Download "SQLite Tools for Windows" (ZIP file).
- Extract the ZIP file to a folder (e.g.,
C:\sqlite
).
2. Add SQLite to System PATH (Optional, for easier access)
- Copy the extracted folder path (e.g.,
C:\sqlite
). - Search for "Environment Variables" in Windows.
- Under System Variables, find and edit the
Path
variable. - Click New and paste
C:\sqlite
. - Click OK to save changes.
Now, you can run sqlite3
from any command prompt.
3. Run SQLite
Option 1: Using Command Prompt
- Open Command Prompt (
cmd
). - Navigate to the SQLite folder (if you didn't add it to PATH):
- Start SQLite by running:
- To open an existing database or create a new one:
- To check tables in the database:
- To exit SQLite:
Option 2: Using SQLite GUI Tools (Optional)
If you prefer a graphical interface, you can download a GUI tool:
- DB Browser for SQLite: https://sqlitebrowser.org/
This tool allows you to easily create and manage SQLite databases without using the command line.
Option 3: Using SQLite with Python
If you want to interact with SQLite in Python, use the sqlite3
module:
Now you have SQLite running on Windows! 🎉 Let me know if you need more help. 🚀
To show all tables in an SQLite database, use the following SQL query:
Explanation:
sqlite_master
: This is a system table in SQLite that stores information about all database objects (tables, indexes, views, triggers).WHERE type='table'
: Filters the results to show only tables (excluding indexes, views, etc.).
Alternative (Using .tables
in SQLite CLI)
If you're using the SQLite command-line interface, you can simply run:
This will list all the tables in the current database.
Let me know if you need help with something specific! 😊
Viewing All Tables
Using sqlite_master table sqlite> SELECT name FROM sqlite_master WHERE type='table'; attempted_hindi_to_eng_ques attempt_log ques_info hindi_to_english_ques_bank user_login Using CLI sqlite> .tables attempt_log ques_info attempted_hindi_to_eng_ques user_login hindi_to_english_ques_bankViewing the create statement for different tables
sqlite> SELECT sql FROM sqlite_master WHERE type='table' AND name='user_login'; CREATE TABLE user_login ( username text PRIMARY KEY, password text NOT NULL ) SELECT sql FROM sqlite_master WHERE type='table' AND name='ques_info'; CREATE TABLE ques_info ( pair_id INTEGER PRIMARY KEY, chapter INTEGER NOT NULL, title TEXT NOT NULL, subject TEXT not null, grade INTEGER NOT NULL, FOREIGN KEY (pair_id) REFERENCES hindi_to_english_ques_bank (pair_id) ) sqlite> SELECT sql FROM sqlite_master WHERE type='table' AND name='hindi_to_english_ques_bank'; CREATE TABLE hindi_to_english_ques_bank ( pair_id INTEGER PRIMARY KEY, hindi text NOT NULL, english text NOT NULL UNIQUE ) sqlite> SELECT sql FROM sqlite_master WHERE type='table' AND name='attempted_hindi_to_eng_ques'; CREATE TABLE attempted_hindi_to_eng_ques ( username text not null, pair_id integer not null, flag integer not null DEFAULT 0, PRIMARY KEY (username, pair_id) FOREIGN KEY (pair_id) REFERENCES hindi_to_english_ques_bank (pair_id) ) SELECT sql FROM sqlite_master WHERE type='table' AND name='attempt_log'; CREATE TABLE attempt_log ( attempt_time DATETIME NOT NULL, username TEXT NOT NULL, pair_id INTEGER NOT NULL, result BOOLEAN NOT NULL, FOREIGN KEY (pair_id) REFERENCES hindi_to_english_ques_bank (pair_id) )Viewing table data
sqlite> select * from ques_info; 1|1.1|Ram and Mango|English|1 2|1.1|Ram and Mango|English|1 3|1.1|Ram and Mango|English|1 4|1.1|Ram and Mango|English|1 5|1.1|Ram and Mango|English|1 6|1.2|To|English|1 7|1.2|To|English|1 8|1.2|To|English|1 9|1.2|To|English|1 10|1.2|To|English|1 11|1.3|Sense Organs|English|1 12|1.3|Sense Organs|English|1 13|1.3|Sense Organs|English|1 14|1.3|Sense Organs|English|1 15|1.3|Sense Organs|English|1 ... sqlite> select * from hindi_to_english_ques_bank; 1|छत पर मत चढ़|Do Not Climb On The Roof 2|राम आम खाता है|Ram Eats Mango 3|वह इंग्लिश पढ़ता है|He Reads English 4|राम ने आम खाया|Ram Ate Mango 5|राम आम खा रहा है|Ram Is Eating Mango 6|वे आम खाते हैं|They Eat Mango 7|राम द्वारा आम खाया जाता है|Mango Is Eaten By Ram 8|हाथ ताली बजाने के लिए|Hands To Clap 9|पैर चलने के लिए|Legs To Walk 10|नाक सूँघने के लिए|Nose To Smell 11|मुँह बातचीत के लिए|Mouth To Talk 12|सिर सोचने के लिए|Head To Think 13|आँखें देखने के लिए|Eyes To See 14|दो छोटे हाथ बजाएं ताली ताली ताली|Two Little Hands Go Clap Clap Clap 15|दो छोटे पैर बजाएं टैप टैप टैप|Two Little Legs Go Tap Tap Tap
No comments:
Post a Comment