Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlite3 prompting `...>` instead of `sqlite>`

Tags:

sqlite

I'm following a beginners tutorial to sqlite3. The first step is creating a new database. So I enter a name (movies.db).

I'm expecting to get another sqlite> prompt on the next line, and continue with the tutorial, but instead I get a lame ...> after which I can type any gibbersish I want. Clearly, this is not good.

What my command prompt looks like:

SQLite version 3.8.1 2013-10-17 12:57:35 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> $ sqlite3 movies.db    ...> gibberish    ...> dsds    ...> sdada    ...> gfgys    ...> a    ...> Aaaaarrrgh!    ...> 

How do I get sqlite3 to work normally for me?

Pardon my newbie-ness. I hope I've phrased this question in a way that might help other newbs too.

like image 875
CodyBugstein Avatar asked Oct 31 '13 15:10

CodyBugstein


People also ask

How do I get out of SQLite prompt?

Ctrl + D will get you out of the SQLite 3 database command prompt. That is: hold the "Ctrl" button then press the lowercase d key on your keyboard at the same time and you will escape the SQLite 3 command prompt.

How do I start SQLite from command prompt?

Open a command prompt (cmd.exe) and 'cd' to the folder location of the SQL_SAFI. sqlite database file. run the command 'sqlite3' This should open the SQLite shell and present a screen similar to that below.

Is SQLite different from sqlite3?

SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. The sqlite3 has no synonyms but sqlite has sqlitedatabase as a solitary synonym. Normally version tags are used for questions about features specific for that version.


2 Answers

Sqlite is working normally. However, the sqlite movies.db command should be issued from your system command line – not from the Sqlite interactive shell. Start by exiting the Sqlite interactive shell (.exit), then issuing the database creation command.

According to the quickstart documentation:

  1. At a shell or DOS prompt, enter: "sqlite3 test.db". This will create a new database named "test.db". (You can use a different name if you like.)

  2. Enter SQL commands at the prompt to create and populate the new database.

Once the sqlite movies.db command is properly executed from your system command line, you'll automatically be placed in the Sqlite interactive shell, which will be awaiting commands.

sqlite> create table tbl1(one varchar(10), two smallint); 

The ...> shell prompt indicates a continuance from the preceding line. As indicated in the message, you'll need to terminate each database command with a ; semicolon.

sqlite> CREATE TABLE tbl2 (    ...>   f1 varchar(30) primary key,    ...>   f2 text,    ...>   f3 real    ...> ); sqlite> 
like image 147
zeantsoi Avatar answered Sep 21 '22 13:09

zeantsoi


Terminate the statement with a ;. So just hit ; then enter and it will go back to normal (after giving an error, because what you've typed here is bad sql).

What's going on is it thinks you are still working on something. It can be useful to break up long queries into lines like this:

sqlite> select title, description    ...> from mytable    ...> where id > 10; 

And the ...> means it is waiting for you to finish your query, which you signify with the semicolon.

like image 27
Adam D. Ruppe Avatar answered Sep 21 '22 13:09

Adam D. Ruppe