13

I installed python3.3 and I am learning django 1.5x. I chose sqlite3 to learn with django and I am running python, django - and trying to run - sqlite3 in command line at windows. All the problem is: where is the file of sqlite3 to run a command like > sqlite3 my_db ?? I tried to found at C:\Python33\Lib\sqlite3;C:\Python33\Lib and search at windows explorer but I really can't find. I am running my projects at C:\projects\mysite

3 Answers 3

16

Assuming that you want to inspect the database created by django, and assuming that the sqlite executable is installed, you can do the following to run sqlite in the command line:

./manage.py dbshell

More information on this command can be found in the django documentation.

Sign up to request clarification or add additional context in comments.

Comments

11

Python itself dosen't contain a sqlite3 command.

But the SQLite library includes a simple command-line utility named sqlite3 (or sqlite3.exe on windows) that allows the user to manually enter and execute SQL commands against an SQLite database. You can download it from here.

Comments

8

Staring from Python 3.12 you can use command line interface to open a SQLite shell.

python3.12 -m sqlite3 [-h] [-v] [filename] [sql]

For example, The following shell will connect to my_db database and execute the query SELECT * FROM your_table;

$ python3.12 -m sqlite3 my_db
sqlite3 shell, running on SQLite version 3.42.0
Connected to 'my_db'

Each command will be run using execute() on the cursor.
Type ".help" for more information; type ".quit" or CTRL-D to quit.
sqlite> SELECT * FROM your_table;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.