Christopher Pisz
Christopher Pisz

Reputation: 4000

Django Tutorial and Sqlite command line

I am going through the Django tutorial at https://docs.djangoproject.com/en/2.2/intro/tutorial02/

It had said previously that if I use sqlite that I don't need to install anything.

Now, it says, after I migrate, ," If you’re interested, run the command-line client for your database and type \dt (PostgreSQL), SHOW TABLES; (MySQL), .schema (SQLite), or SELECT TABLE_NAME FROM USER_TABLES; (Oracle) to display the tables Django created. "

Am I supposed to have a command line editor for sqlite already or do I need to go fetch something from the web? If the latter, what do I get? If the former, what is the command to start it up?

Upvotes: 2

Views: 5858

Answers (2)

yaya
yaya

Reputation: 8243

I figured it out. on windows :

  1. download sqlite-tools (there is separate sqlite-tools for each OS. download based on your OS.) from : https://www.sqlite.org/download.html
  2. put 3 .exe files in : C:\Program Files\sqlite3
  3. add C:\Program Files\sqlite3 to windows PATH ENV Variable. (click if you don't know how)
  4. you may now open command prompt and run:

cd <DjangoProjectPath>

sqlite3 db.sqlite3

Inside sqlite shell: .schema

Now it works without any error.

Upvotes: 1

dirkgroten
dirkgroten

Reputation: 20672

It looks like you already have everything installed.

In your terminal, just type sqlite3 to start the sqlite command-line tool. Then use .help to see all the available commands. You can .open your database or you can run sqlite3 /path/to/db.sqlite directly to run the tool with your django db already open.

With the command .schema you'll be able to see all your tables structure. But you can also directly run a sql command like SELECT * FROM polls_question;

Upvotes: 1

Related Questions