Connecting to SQLite from the command line
SQLite is a lightweight, serverless database engine. On ruachost.com, you can connect to SQLite databases directly from the command line using the sqlite3 program.
Why Use the Command Line?
Section titled “Why Use the Command Line?”- Quick and easy access to SQLite databases.
- Run SQL queries without needing a GUI.
- Useful for debugging, scripting, and development.
Steps to Connect to SQLite
Section titled “Steps to Connect to SQLite”Step 1: Log in via SSH
Section titled “Step 1: Log in via SSH”- Use SSH to connect to your hosting account:
ssh username@yourserver.ruachost.comStep 2: Run the sqlite3 Command
Section titled “Step 2: Run the sqlite3 Command”-
At the command line, type:
Terminal window sqlite3 example.db -
Replace
example.dbwith the name of your database file. -
If the file does not exist, SQLite will create it.
-
If the file exists, SQLite will open the database contained in it.
Step 3: Use SQLite Commands
Section titled “Step 3: Use SQLite Commands”Once inside the sqlite> prompt, you can run SQL queries and special commands:
-
Show tables
Section titled “Show tables”.tables -
View table structure
Section titled “View table structure”Terminal window .schema tablename -
List all commands
Section titled “List all commands”Terminal window .help -
Exit SQLite
Section titled “Exit SQLite”
.quit