Django – 想要使用inspectdb只获取一个表。使用MS SQL Server

huangapple go评论62阅读模式
英文:

Django - want to use inspectdb to get only one table. Using MS SQL Server

问题

I've been testing the inspectdb with django 4.0. If I do "python manage.py inspectdb --database MSDatabase," it tries to bring all table info into the model. Is there a way to select only a few or one table?

The DB server is MS SQL Server. The database is MSDatabase, the schema is MySchema, and the table name is MYTBL.

I tried "python manage.py inspectdb --database MSDatabase MYTBL" and got the table not found error.

英文:

I've been testing the inspectdb with django 4.0. If I do "python manage.py inspectdb --database MSDatabase", it tries to bring all table info into the model. Is there a way to select only few or one tables?

The DB server is MS SQL Server. The database is MSDatabase, the schema is MySchema, and the table name is MYTBL.

I tried "python manage.py inspectdb --database MSDatabase MYTBL" and got the table not found error.

答案1

得分: 1

你可以将表格的名称传递给它。

python manage.py inspectdb table1

或者多个表格

python manage.py inspectdb table1 table2

这是Django 4.0的inspectdb文档链接

英文:

You can pass the name of the table to do it.

python manage.py inspectdb table1

Or multiple tables

python manage.py inspectdb table1 table2

Here's the the link to inspectdb documention for Django 4.0.

答案2

得分: 0

对我来说,这个方法有效。

python manage.py inspectdb --database MyDb table1
英文:

For me this worked.

python manage.py inspectdb --database MyDb table1

huangapple
  • 本文由 发表于 2023年6月8日 13:12:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76428781.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定