Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django - South - Is There a way to view the SQL it runs?

Here's what I want to do.

Develop a Django project on a development server with a development database. Run the south migrations as necessary when I change the model.

Save the SQL from each migration, and apply those to the production server when I'm ready to deploy.

Is such a thing possible with South? (I'd also be curious what others do to get your development database changes on production when working with Django)

like image 962
Greg Avatar asked Apr 29 '11 14:04

Greg


People also ask

What is the difference between SQL and Django?

Django and SQL are not replacements for one another, Django is a web framework as a whole, designed to develop web applications, and SQL is a language to query databases.

What is a Django query?

A QuerySet is a collection of data from a database. A QuerySet is built up as a list of objects. QuerySets makes it easier to get the data you actually need, by allowing you to filter and order the data.


2 Answers

You can at least inspect the sql generated by doing manage.py migrate --db-dry-run --verbosity=2. This will not do anything to the database and will show all the sql. I would still make a backup though, better safe than sorry.

like image 198
Lutger Avatar answered Sep 21 '22 16:09

Lutger


 python manage.py sqlmigrate <app_label> <migration_name> 
like image 30
Flimm Avatar answered Sep 20 '22 16:09

Flimm