mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
[soc2009/multidb] Modified the fixture loading, fixture dumping and synchronization process to be multi-db aware. Patch from Russell Keith-Magee.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11763 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -121,11 +121,10 @@ createcachetable
|
||||
Creates a cache table named ``tablename`` for use with the database cache
|
||||
backend. See :ref:`topics-cache` for more information.
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The alias for the database to install the cachetable to. By default uses the
|
||||
``'default'`` alias.
|
||||
The :djadminopt:`--database` option can be used to specify the database
|
||||
onto which the cachetable will be installed.
|
||||
|
||||
createsuperuser
|
||||
---------------
|
||||
@@ -173,11 +172,10 @@ 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.
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The alias for the database to open the shell for. By default uses the
|
||||
``'default'`` alias.
|
||||
The :djadminopt:`--database` option can be used to specify the database
|
||||
onto which to open a shell.
|
||||
|
||||
|
||||
diffsettings
|
||||
@@ -212,21 +210,6 @@ records to dump. If you're using a :ref:`custom manager <custom-managers>` as
|
||||
the default manager and it filters some of the available records, not all of the
|
||||
objects will be dumped.
|
||||
|
||||
.. django-admin-option:: --exclude
|
||||
|
||||
.. versionadded:: 1.0
|
||||
|
||||
Exclude a specific application from the applications whose contents is
|
||||
output. For example, to specifically exclude the `auth` application from
|
||||
the output, you would call::
|
||||
|
||||
django-admin.py dumpdata --exclude=auth
|
||||
|
||||
If you want to exclude multiple applications, use multiple ``--exclude``
|
||||
directives::
|
||||
|
||||
django-admin.py dumpdata --exclude=auth --exclude=contenttypes
|
||||
|
||||
.. django-admin-option:: --format <fmt>
|
||||
|
||||
By default, ``dumpdata`` will format its output in JSON, but you can use the
|
||||
@@ -239,6 +222,11 @@ By default, ``dumpdata`` will output all data on a single line. This isn't
|
||||
easy for humans to read, so you can use the ``--indent`` option to
|
||||
pretty-print the output with a number of indentation spaces.
|
||||
|
||||
.. versionadded:: 1.0
|
||||
|
||||
The :djadminopt:`--exclude` option may be provided to prevent specific
|
||||
applications from being dumped.
|
||||
|
||||
.. versionadded:: 1.1
|
||||
|
||||
In addition to specifying application names, you can provide a list of
|
||||
@@ -247,6 +235,11 @@ name to ``dumpdata``, the dumped output will be restricted to that model,
|
||||
rather than the entire application. You can also mix application names and
|
||||
model names.
|
||||
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The :djadminopt:`--database` option can be used to specify the database
|
||||
onto which the data will be loaded.
|
||||
|
||||
flush
|
||||
-----
|
||||
|
||||
@@ -260,10 +253,10 @@ fixture will be re-installed.
|
||||
The :djadminopt:`--noinput` option may be provided to suppress all user
|
||||
prompts.
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The alias for the database to flush. By default flushes all databases.
|
||||
The :djadminopt:`--database` option may be used to specify the database
|
||||
to flush.
|
||||
|
||||
|
||||
inspectdb
|
||||
@@ -309,11 +302,10 @@ needed.
|
||||
``inspectdb`` works with PostgreSQL, MySQL and SQLite. Foreign-key detection
|
||||
only works in PostgreSQL and with certain types of MySQL tables.
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The alias for the database to introspect. By default uses the ``'default'``
|
||||
alias.
|
||||
The :djadminopt:`--database` option may be used to specify the
|
||||
database to introspect.
|
||||
|
||||
|
||||
loaddata <fixture fixture ...>
|
||||
@@ -323,6 +315,11 @@ loaddata <fixture fixture ...>
|
||||
|
||||
Searches for and loads the contents of the named fixture into the database.
|
||||
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The :djadminopt:`--database` option can be used to specify the database
|
||||
onto which the data will be loaded.
|
||||
|
||||
What's a "fixture"?
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -404,6 +401,37 @@ installation will be aborted, and any data installed in the call to
|
||||
references in your data files - MySQL doesn't provide a mechanism to
|
||||
defer checking of row constraints until a transaction is committed.
|
||||
|
||||
Database-specific fixtures
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
If you are in a multi-database setup, you may have fixture data that
|
||||
you want to load onto one database, but not onto another. In this
|
||||
situation, you can add database identifier into . If your
|
||||
:setting:`DATABASES` setting has a 'master' database defined, you can
|
||||
define the fixture ``mydata.master.json`` or
|
||||
``mydata.master.json.gz``. This fixture will only be loaded if you
|
||||
have specified that you want to load data onto the ``master``
|
||||
database.
|
||||
|
||||
Excluding applications from loading
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The :djadminopt:`--exclude` option may be provided to prevent specific
|
||||
applications from being loaded.
|
||||
|
||||
For example, if you wanted to exclude models from ``django.contrib.auth``
|
||||
from being loaded into your database, you would call::
|
||||
|
||||
django-admin.py loaddata mydata.json --exclude auth
|
||||
|
||||
This will look for for a JSON fixture called ``mydata`` in all the
|
||||
usual locations - including the ``fixtures`` directory of the
|
||||
``django.contrib.auth`` application. However, any fixture object that
|
||||
identifies itself as belonging to the ``auth`` application (e.g.,
|
||||
instance of ``auth.User``) would be ignored by loaddata.
|
||||
|
||||
makemessages
|
||||
------------
|
||||
|
||||
@@ -465,10 +493,10 @@ Executes the equivalent of ``sqlreset`` for the given app name(s).
|
||||
The :djadminopt:`--noinput` option may be provided to suppress all user
|
||||
prompts.
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The alias for the database to reset. By default resets all databases.
|
||||
The :djadminopt:`--database` option can be used to specify the alias
|
||||
of the database to reset.
|
||||
|
||||
Executes the equivalent of ``sqlreset`` for the given app name(s).
|
||||
|
||||
@@ -592,12 +620,10 @@ sql <appname appname ...>
|
||||
|
||||
Prints the CREATE TABLE SQL statements for the given app name(s).
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
|
||||
The alias for the database to print the SQL for. By default uses the
|
||||
``'default'`` alias.
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The :djadminopt:`--database` option can be used to specify the database for
|
||||
which to print the SQL.
|
||||
|
||||
sqlall <appname appname ...>
|
||||
----------------------------
|
||||
@@ -609,11 +635,10 @@ Prints the CREATE TABLE and initial-data SQL statements for the given app name(s
|
||||
Refer to the description of ``sqlcustom`` for an explanation of how to
|
||||
specify initial data.
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The alias for the database to print the SQL for. By default uses the
|
||||
``'default'`` alias.
|
||||
The :djadminopt:`--database` option can be used to specify the database for
|
||||
which to print the SQL.
|
||||
|
||||
sqlclear <appname appname ...>
|
||||
------------------------------
|
||||
@@ -622,11 +647,10 @@ sqlclear <appname appname ...>
|
||||
|
||||
Prints the DROP TABLE SQL statements for the given app name(s).
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The alias for the database to print the SQL for. By default uses the
|
||||
``'default'`` alias.
|
||||
The :djadminopt:`--database` option can be used to specify the database for
|
||||
which to print the SQL.
|
||||
|
||||
sqlcustom <appname appname ...>
|
||||
-------------------------------
|
||||
@@ -649,11 +673,10 @@ table modifications, or insert any SQL functions into the database.
|
||||
|
||||
Note that the order in which the SQL files are processed is undefined.
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The alias for the database to print the SQL for. By default uses the
|
||||
``'default'`` alias.
|
||||
The :djadminopt:`--database` option can be used to specify the database for
|
||||
which to print the SQL.
|
||||
|
||||
sqlflush
|
||||
--------
|
||||
@@ -663,11 +686,10 @@ sqlflush
|
||||
Prints the SQL statements that would be executed for the :djadmin:`flush`
|
||||
command.
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The alias for the database to print the SQL for. By default uses the
|
||||
``'default'`` alias.
|
||||
The :djadminopt:`--database` option can be used to specify the database for
|
||||
which to print the SQL.
|
||||
|
||||
sqlindexes <appname appname ...>
|
||||
--------------------------------
|
||||
@@ -676,11 +698,10 @@ sqlindexes <appname appname ...>
|
||||
|
||||
Prints the CREATE INDEX SQL statements for the given app name(s).
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The alias for the database to print the SQL for. By default uses the
|
||||
``'default'`` alias.
|
||||
The :djadminopt:`--database` option can be used to specify the database for
|
||||
which to print the SQL.
|
||||
|
||||
sqlreset <appname appname ...>
|
||||
------------------------------
|
||||
@@ -689,11 +710,10 @@ sqlreset <appname appname ...>
|
||||
|
||||
Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s).
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The alias for the database to print the SQL for. By default uses the
|
||||
``'default'`` alias.
|
||||
The :djadminopt:`--database` option can be used to specify the database for
|
||||
which to print the SQL.
|
||||
|
||||
sqlsequencereset <appname appname ...>
|
||||
--------------------------------------
|
||||
@@ -708,11 +728,10 @@ number for automatically incremented fields.
|
||||
Use this command to generate SQL which will fix cases where a sequence is out
|
||||
of sync with its automatically incremented field data.
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The alias for the database to print the SQL for. By default uses the
|
||||
``'default'`` alias.
|
||||
The :djadminopt:`--database` option can be used to specify the database for
|
||||
which to print the SQL.
|
||||
|
||||
startapp <appname>
|
||||
------------------
|
||||
@@ -770,17 +789,16 @@ with an appropriate extension (e.g. ``json`` or ``xml``). See the
|
||||
documentation for ``loaddata`` for details on the specification of fixture
|
||||
data files.
|
||||
|
||||
--database
|
||||
~~~~~~~~~~
|
||||
|
||||
The alias for the database install the tables for. By default uses the
|
||||
``'default'`` alias.
|
||||
|
||||
--noinput
|
||||
~~~~~~~~~
|
||||
The :djadminopt:`--noinput` option may be provided to suppress all user
|
||||
prompts.
|
||||
|
||||
.. versionadded:: 1.2
|
||||
|
||||
The :djadminopt:`--database` option can be used to specify the database to
|
||||
synchronize.
|
||||
|
||||
test <app or test identifier>
|
||||
-----------------------------
|
||||
|
||||
@@ -922,6 +940,30 @@ Common options
|
||||
The following options are not available on every commands, but they are
|
||||
common to a number of commands.
|
||||
|
||||
.. django-admin-option:: --database
|
||||
|
||||
.. versionadded:: 1.2
|
||||
|
||||
Used to specify the database on which a command will operate. If not
|
||||
specified, this option will default to an alias of ``default``.
|
||||
|
||||
For example, to dump data from the database with the alias ``master``::
|
||||
|
||||
django-admin.py dumpdata --database=master
|
||||
|
||||
.. django-admin-option:: --exclude
|
||||
|
||||
Exclude a specific application from the applications whose contents is
|
||||
output. For example, to specifically exclude the `auth` application from
|
||||
the output of dumpdata, you would call::
|
||||
|
||||
django-admin.py dumpdata --exclude=auth
|
||||
|
||||
If you want to exclude multiple applications, use multiple ``--exclude``
|
||||
directives::
|
||||
|
||||
django-admin.py dumpdata --exclude=auth --exclude=contenttypes
|
||||
|
||||
.. django-admin-option:: --locale
|
||||
|
||||
Use the ``--locale`` or ``-l`` option to specify the locale to process.
|
||||
|
||||
Reference in New Issue
Block a user