[步骤] Django 数据表的重建 (不影响原有的数据)

注意:

在重建 Django 数据表之前要先安装 Django 服务

正文:

(django_env) [root@python mysite]# python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying sessions.0001_initial... OK

[工具] Python 随意生成一个 json 文件

介绍

使用方法

1. 给此脚本添加执行权限
2. 执行此脚本

注意

此脚本不能命名为 json.py

脚本

#!/usr/bin/python3

import json
hostlist = {}
hostlist["web"] = ["192.168.100.101", "192.168.100.102"]

hostlist["db"] = {
        "hosts" :["192.168.100.121", "192.168.100.122"],
        "vars" :{"ansible_ssh_user":"root", "ansible_ssh_pass":"1"}
        }

hostlist["192.168.100.110"] = {
        "ansible_ssh_user":"root", "ansible_ssh_pass":"pwd"
        }

print(json.dumps(hostlist))