diff options
Diffstat (limited to 'django/core/management/commands/createcachetable.py')
| -rw-r--r-- | django/core/management/commands/createcachetable.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/django/core/management/commands/createcachetable.py b/django/core/management/commands/createcachetable.py index 4a6456b536..f80fa8834e 100644 --- a/django/core/management/commands/createcachetable.py +++ b/django/core/management/commands/createcachetable.py @@ -15,16 +15,20 @@ class Command(BaseCommand): requires_system_checks = False def add_arguments(self, parser): - parser.add_argument('args', metavar='table_name', nargs='*', - help='Optional table names. Otherwise, settings.CACHES is used to ' - 'find cache tables.') - parser.add_argument('--database', action='store', dest='database', + parser.add_argument( + 'args', metavar='table_name', nargs='*', + help='Optional table names. Otherwise, settings.CACHES is used to find cache tables.', + ) + parser.add_argument( + '--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database onto which the cache tables will be ' - 'installed. Defaults to the "default" database.') - parser.add_argument('--dry-run', action='store_true', dest='dry_run', - help='Does not create the table, just prints the SQL that would ' - 'be run.') + 'installed. Defaults to the "default" database.', + ) + parser.add_argument( + '--dry-run', action='store_true', dest='dry_run', + help='Does not create the table, just prints the SQL that would be run.', + ) def handle(self, *tablenames, **options): db = options['database'] @@ -72,9 +76,10 @@ class Command(BaseCommand): field_output.append("UNIQUE") if f.db_index: unique = "UNIQUE " if f.unique else "" - index_output.append("CREATE %sINDEX %s ON %s (%s);" % - (unique, qn('%s_%s' % (tablename, f.name)), qn(tablename), - qn(f.name))) + index_output.append( + "CREATE %sINDEX %s ON %s (%s);" % + (unique, qn('%s_%s' % (tablename, f.name)), qn(tablename), qn(f.name)) + ) table_output.append(" ".join(field_output)) full_statement = ["CREATE TABLE %s (" % qn(tablename)] for i, line in enumerate(table_output): @@ -89,8 +94,7 @@ class Command(BaseCommand): self.stdout.write(statement) return - with transaction.atomic(using=database, - savepoint=connection.features.can_rollback_ddl): + with transaction.atomic(using=database, savepoint=connection.features.can_rollback_ddl): with connection.cursor() as curs: try: curs.execute(full_statement) |
