如何检查包含1000个表的数据库中的1个表 [英] How do I inspectdb 1 table from database which Contains 1000 tables
本文介绍了如何检查包含1000个表的数据库中的1个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含1000个表的模式,其中有许多我不需要的表, 我怎样才能只检查我需要的表?
I got a schema which Contains 1000 tables,and many of them I don't need, how can I just inspectdb the just tables that I need?
推荐答案
您可以在python控制台中或在* .py文件中进行此操作:
You can do it in the python console, or in *.py file:
from django.core.management.commands.inspectdb import Command
from django.conf import settings
from your_project_dir.settings import DATABASES # replace `your_project_dir`
settings.configure()
settings.DATABASES = DATABASES
Command().execute(table_name_filter=lambda table_name: table_name in ('table_what_you_need_1', 'table_what_you_need_2', ), database='default')
https://github.com. com/django/django/blob/master/django/core/management/commands/inspectdb.py#L32
这篇关于如何检查包含1000个表的数据库中的1个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文