Python Manage.py Dbshell Doesn't Find Psycopg2 Although It Is Installed And In Path
Solution 1:
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 a simple command-line
utility named sqlite3
. 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
this postgres
needs package to initialize. postgresql need postgresql_psycopg2 package
Solution 2:
You need to install sqlite3 to be able to run dbshell
Installing the sqlite program should solve the problem:
sudo apt-get install sqlite3
Solution 3:
I think there is some confusion as to what dbshell does. From the documentation:
Runs the command-line client for the database engine specified in your ENGINE setting, with the connection parameters specified in your USER, PASSWORD, etc., settings.
- For PostgreSQL, this runs the
psql
command-line client.- For MySQL, this runs the
mysql
command-line client.- For SQLite, this runs the
sqlite3
command-line client.This command assumes the programs are on your PATH so that a simple call to the program name (psql, mysql, sqlite3) will find the program in the right place. There’s no way to specify the location of the program manually.
Its not like manage.py shell
, dbshell
just runs the normal shell for the database configured, except it logs you in with the credentials in settings.py
.
This means, if you are using postgresql, you need to have the psql
command already installed in order for dbshell
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.
Post a Comment for "Python Manage.py Dbshell Doesn't Find Psycopg2 Although It Is Installed And In Path"