Django: using more than one database with inspectdb?

后端 未结 3 2396
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-20 02:04

My settings file\'s database section looks like this:

DATABASES = {
    \'default\': {
        \'ENGINE\': \'django.db.backends.sqlite3\',
        \'NAME\': \'C:         


        
相关标签:
3条回答
  • 2021-02-20 02:18

    If you are trying @solarissmoke's answer for Django 2.*:

    Don't wrap the database name with quotes, otherwise it will give you a KeyError and a ConnectionDoesnotExist error.

    python manage.py inspectdb --database blah
    
    0 讨论(0)
  • 2021-02-20 02:22

    You can specify a specific database like this:

    python manage.py inspectdb --database=blah > you_app/models.py
    
    0 讨论(0)
  • 2021-02-20 02:40

    From the documentation:

    --database DATABASE

    Specifies the database to introspect. Defaults to default.

    So you can inspect your second database with:

    python manage.py inspectdb --database blah
    

    You cannot inspect both at the same time.

    0 讨论(0)
提交回复
热议问题