I'd like to be issuing SQL commands via python manage.py dbshell but I get the error "CommandError: You appear not to have the 'sqlite3' program installed or on your path". From the python prompt I can import psycopg2 without getting any errors and psycopg2 appears to be in my python path.
I'm trying django and my settings.py specifies "ENGINE": "django.db.backends.postgresql_psycopg2"
Any help would be greatly appreciated,
Thanks, Julian
You need to install sqlite3 to be able to run dbshell
Installing the sqlite program should solve the problem:
when you run
./manage.py dbshell psql or sqlite3
this command assumes the programs are on your PATH. this will simply calls the program name.sqlite3
from Python itself dosen't contain a
sqlite3
command. if you want to access from the command line you have to install SQLite library that includes asimple command-line
utility namedsqlite3
. but without installing library you can create the db server because it doesn’t require running a separate server and sqlite3 itself a text based file.If you are developing a simple project or something you don’t plan to deploy in a production environment, then use
SQLite
in your case first install sqlite3 using
sudo apt-get install sqlite3 libsqlite3-dev
to access dbshell.postgres
compare to
sqlite3
thispostgres
needs package to initialize. postgresql need postgresql_psycopg2 packageI think there is some confusion as to what dbshell does. From the documentation:
Its not like
manage.py shell
,dbshell
just runs the normal shell for the database configured, except it logs you in with the credentials insettings.py
.This means, if you are using postgresql, you need to have the
psql
command already installed in order fordbshell
to work. This command is not part of Python, but comes with the postgresql server.In order words - if all you have installed is psycopg2, the
dbshell
command will not work.