FAQ: Databases and models

    connection.queries is only available if DEBUG is True.It’s a list of dictionaries in order of query execution. Each dictionary hasthe following:

    includes all SQL statements – INSERTs, UPDATES,SELECTs, etc. Each time your app hits the database, the query will be recorded.

    If you are using , you can use thesame interface on each member of the connections dictionary:

    Can I use Django with a pre-existing database?

    Yes. See .

    Take a look at Django’s support for schema migrations.

    If you don’t mind clearing data, your project’s manage.py utility has a option to reset the database to the state it was inimmediately after migrate was executed.

    Do Django models support multiple-column primary keys?

    But this isn’t an issue in practice, because there’s nothing stopping you fromadding other constraints (using the unique_together model option orcreating the constraint directly in your database), and enforcing theuniqueness at that level. Single-column primary keys are needed for things suchas the admin interface to work; e.g., you need a single value to specifyan object to edit or delete.

    NoSQL databases are not officially supported by Django itself. There are,however, a number of side project and forks which allow NoSQL functionality inDjango, like Django non-rel.

    You can also take a look on which discusses some alternatives.

    How do I add database-specific options to my CREATE TABLE statements, such as specifying MyISAM as the table type?

    For example, if you’re using MySQL and want your tables to use the MyISAM tabletype, use the following SQL: