Connect to sample Database
(1.1) By Thruss on 2020-09-14 15:58:35 edited from 1.0
I am on the tutorial: https://www.sqlitetutorial.net/sqlite-sample-database/ STEP 1: Instruction is: navigate to the C:\sqlite folde Code is : C:\>cd\sqlite result is: C:\sqlite> STEP 2: Instruction is: type sqlite3 and press enter Code is: C:\>cd\sqlite result is: C:\sqlite> STEP 3: Instruction is: type sqlite3 and press enter, you should see the following output Code is: C:\sqlite>sqlite3 Result is (and it compares to the example): SQLite version 3.33.0 2020-08-14 13:23:32 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite> STEP 4 Instruction: type the .help command from the sqlite> prompt to see all available commands in sqlite3. Code is: sqlite> .help Result is: a list of help commands / information similar to example STEP 5 Instruction: it tells you to quit and to download a GUI. I am not quitting, and moving on to the next instructions to download and unzip the demo file called chinook.db Mine is in a folder called : C:\sqlite\db STEP 6: Instruction: use the following command to connect to the chinook sample database located in the db folder, which is a subfolder of the sqlite folder. Code: C:\sqlite>sqlite3 c:\db\chinook.db Result: SQLite version 3.33.0 2020-08-14 13:23:32 Enter ".help" for usage hints. sqlite> It says I should see a folder called sqlite> which I do STEP 7: Instruction: try a simple command like seeing the tables Code: sqlite> .tables Result: Error: unable to open database "c:\db\chinook.db": unable to open database file I hope this makes more sense. Sorry, I am doing everything in DOS CMD and think I am doing it right, but in case you have not noticed, I am not a guru :-)
(2) By Larry Brasfield (LarryBrasfield) on 2020-09-14 15:27:03 in reply to 1.0 [link]
Please edit your post to show, on separate lines, exactly what you are typing and in what context (such as at cmd.exe command prompt, sqlite prompt). Also, instead of saying "does not work" or "cannot get it to work", say what happened that you interpreted as not working. I see several possible reasons for your difficulty: (1) You are typing in the prompt text shown in the tutorial; (2) You are entering an invocation meaningful to cmd.exe as a command but while sqlite3.exe is running; or (3) You have put the database in a different location than where you told sqlite3.exe to find it. My above suggestions will help forum participants to distinguish among those possibilities. To better show what you entered and what responses were emitted, put them in code constructs such as this: ``` <code> ``` <code>The stuff to be shown as entered goes here.</code> ``` </code> ```
(3) By David Raymond (dvdraymond) on 2020-09-14 15:28:46 in reply to 1.0 [link]
The message displayed when you run sqlite3 tells you what's going on. When you run just sqlite3 from the command line it opens up the CLI "to a transient in-memory database" where you can make tables, run queries, etc. But you're in the CLI now and are using _its_ command prompt, and not Windows', so to open your "persistent database" you would use the .open command. sqlite3 C:\path\to\file\here.db is what you would run from the Windows command prompt to start the CLI with it opening a specific db. You're trying to do that command when you're already in the CLI interface, which is the problem.
(4) By TripeHound on 2020-09-14 15:35:12 in reply to 1.0 [link]
First, to the best of my knowledge, that tutorial site has no official connection to "core" SQLite and this forum... any difficulties with the _tutorial_ are probably best addressed to that site. Having said that, your problem is confusing a CMD command-line with an SQLite command-line (I've not looked at the tutorial, so I don't know if it's their fault for not making it clear enough `:-)`) To address the "cannot get out of"... any SQL statements given to the SQLite shell needs to be terminated with a semi-colon. These commands can span multiple lines (hence the ` ...>` prompt), so you are being prompted to enter the rest of the command, together with the terminating semi-colon. To get out, type `;` and press `ENTER` (you'll get an error message of some kind: ignore it) then type `.quit` (or just `.q`) and press `ENTER`. This will return you to the command-prompt. (In passing, any command starting with a full-stop are "internal" commands to the SQLite shell, and are _not_ SQL statements. As such, they do _not_ need to be terminated with a semi-colon). Your main problem is that `sqlite3 c:\sqlite\db\chinook.db` is a command-line command: start the SQLite shell _and_ open the database `c:\sqlite\db\chinook.db`. If you give this now (instead of just `sqlite3`) things should get one step further. You _can_ use the SQLite shell's `.open` command to open a database after you've launched the shell, but you have to "fight" with backslashes (either doubling them, or using forward-slashes instead).
(5) By Thruss on 2020-09-14 16:08:17 in reply to 3 [link]
Oh my life - I am using your code ad it works. Thank you so much.