0

I used the following on the cmd to try and open the sqlite command line interface, but somehow it is not recognised.

I can see the sqlite db has been created, so cannot see what I am doing wrong:

(env) E:\Python installation\myproject\myflaskproject>sqlite
'sqlite' is not recognized as an internal or external command,
operable program or batch file.

(env) E:\Python installation\myproject\myflaskproject>

I've also tried typing at the prompt: >>sqlite3

Still, the same error.

3

1 Answer 1

4

download slqlit3

to download slqlit3 go to this url: https://www.sqlite.org/download.html

since your are working on windows platform, under Precompiled Binaries for Windows section download sqlite-tools-win64-x64-3320300.zip or sqlite-tools-win32-x86-3320300.zip if your are like me working on the very OLD windows 7 32bit architecture

you have to know sqlite3 is a standalone and executable file meaning sqlite3 don't require to be installed like other programs:

A bundle of command-line tools for managing SQLite database files, including the command-line shell program, the sqldiff.exe program, and the sqlite3_analyzer.exe program.

unzip the downloaded file the under C:\ for e.g. and rename the folder to C:\sqlite3 to make things simple.

now, if you open : C:\sqlite3, you'll find 3 executable files:

C:\sqlite3
  sqldiff.exe
  **sqlite3.exe**
  sqlite3_analyzer.exe

add an Environment Variable

  • open System Properties (see this post)
  • go to Advanced tab under System Properties and click Environment Variables
  • Under System Variables create those variables:
    • PYTHON_HOME = C:\Python37 (it depends where you already installed python and which version if you have multiple installations)
    • SQLITE_HOME = C:\sqlite3
  • go to User variables and add/append variables to PATH like so:
    • PATH = [..];%PYTHON_HOME%;%PYTHON_HOME%\Scripts;

open new console and check your current active python:

python --version

and then you can use sqlite3 command not sqlite (check the C:\sqlite3 installation folder):

(env) E:\Python installation\myproject\myflaskproject>sqlite
'sqlite' is not recognized as an internal or external command,
operable program or batch file.

(env) E:\Python installation\myproject\myflaskproject>sqlite3 -version
3.15.2 2016-11-28 19:13:37 bbd85d235f7037c6a033a9690534391ffeacecc8

now you can open the sqlite database file (e.g: data-dev.sqlite3 under /myflaskproject ) like

(env) E:\Python installation\myproject\myflaskproject>sqlite3 data-dev.sqlite3
SQLite version 3.15.2 2016-11-28 19:13:37
Enter ".help" for usage hints.
sqlite>

some quick useful sqlite commands

sqlite> .databases
seq  name             file

---  ---------------  ----------------------------------------------------------

0    main             E:\Python installation\myproject\myflaskproject\data-dev.sqlite3

sqlite> .tables
user
sqlite> .exit (to exit)

for more about sqlite have look at this site sqlitetutorial.net

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

7 Comments

I haven't downloaded it - but shouldn't it be packaged with flask. The tutorial followed doesn't explcitly download it...
Flask is un-opinionated micro-framework that means Flask won’t make decisions for you, such as what database to use nor chipping an external executable (sqlite3.exe) and not even support for any database (builtin classes, libs) if you want, you can install an extension that extends Flask capabilities like the famous Flask-SALAlchemy
if my answer was useful for you consider accepting it.
I need to verify it works....thank you. Any thoughts on this: stackoverflow.com/questions/62579373/…
(env) E:\Python installation\myproject\myflaskproject>pip install sqlite3 Collecting sqlite3 ERROR: Could not find a version that satisfies the requirement sqlite3 (from versions: none) ERROR: No matching distribution found for sqlite3 WARNING: You are using pip version 19.2.3, however version 20.1.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. (env) E:\Python installation\myproject\myflaskproject>
|

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.