I opened sqlite3.exe application located in this folder:
C:\Users\myname\AppData\Local\anaconda3\Library\bin
The terminal comes up with the following prompt:
sqlite>
I have my my.db file located in C:\Users\myname\Desktop\sqlite-python
How do I run this code to connect to my database?
sqlite3 my.db
when I tried a few variation of the above code I kept getting new line of ...> in the terminal.
The issue you're encountering is related to how the SQLite command-line shell interprets input. Here's how you can properly connect to your database and avoid the ...>
continuation prompt:
Ensure you are in the SQLite Shell:
When you open sqlite3.exe, you should see the sqlite>
prompt.
Connect to the Database:
To open your my.db database, you need to use the .open
command with the full or relative path to your database file. Since your database is located in C:\Users\myname\Desktop\sqlite-python
, use:
.open "C:/Users/myname/Desktop/sqlite-python/my.db"
Note:
Use forward slashes (/) or double backslashes (\) for the path to avoid issues with escape sequences in Windows. Ensure the path is correct and your my.db file exists. Verify the Connection: Once connected, you can check the tables in the database by using:
.tables
If your database is empty, this command will return nothing.
Addressing ...>
Issue:
If you see the ...>
continuation prompt, it means SQLite is waiting for you to complete a multi-line statement. To cancel, press Ctrl+C or enter a semicolon (;) to end the statement.
Running SQL Queries: You can now execute SQL queries. For example:
SELECT * FROM some_table;
Exiting SQLite: When you're done, type:
.exit
If you want to open the database directly when starting the sqlite3 application, you can pass the path as a command-line argument:
sqlite3 "C:/Users/myname/Desktop/sqlite-python/my.db"
This will open the database directly without needing to use .open
.