3

I'm following this tutorial http://www.sitepoint.com/building-simple-rest-api-mobile-applications/

I'm trying to run SQL by

$ python manage.py sql fishes

However it says

Unknown Command: 'sql'

If I type

$ python manage.py help

I get this, and SQL doesn't appear in the list.

Available subcommands:

[auth]
    changepassword
    createsuperuser

[django]
    check
    compilemessages
    createcachetable
    dbshell
    diffsettings
    dumpdata
    flush
    inspectdb
    loaddata
    makemessages
    makemigrations
    migrate
    sendtestemail
    shell
    showmigrations
    sqlflush
    sqlmigrate
    sqlsequencereset
    squashmigrations
    startapp
    startproject
    test
    testserver

[sessions]
    clearsessions

[staticfiles]
    collectstatic
    findstatic
    runserver
3
  • 4
    Yes, indeed that command does not exist any more. You should use a more up-to-date tutorial. Commented Mar 17, 2016 at 16:38
  • Is there no alternative? Commented Mar 17, 2016 at 16:44
  • The tutorial says "Run python manage.py sql fishes to see a preview", so you can probably just ignore that line and carry on the tutorial. It's a good idea to find a more up-to-date tutorial anyway - there might be other things that don't work if you are using a different version of Django to the tutorial. Commented Mar 17, 2016 at 16:54

2 Answers 2

3

Unfortunately that doesn't exist any more, however the command manage.py dbshell does.

Generally speaking however, you should try to use models, with load_data etc to preserve the data integrity (as validations etc may happen in models rather then relying on underlying data bits). Or write management commands for any clean up tasks.

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

Comments

0

Yes it is possible, using the inspectdb command:

python manage.py inspectdb

or

python manage.py inspectdb > models.py

to get them in into the file

This will look at the database configured in your settings.py and outputs model classes to standard output.

As Ignacio pointed out, there is a guide for your situation in the documentation.

Source : link

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.