尝试检查 MsSql 数据库时出现此错误:
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models
# Unable to inspect table 'test_table'
# The error was: __new__() missing 1 required positional argument: 'collation'
这是我使用的命令:
python manage.py inspectdb test_table --database=some_db --verbosity=3
这是settings.py中的连接:
'some_db':{
'ENGINE': 'sql_server.pyodbc',
'NAME': os.environ['name'],
'USER': os.environ['user'],
'PASSWORD': os.environ['pw'],
'HOST': os.environ['db'],
'PORT': os.environ['port'],
'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
'unicode_results': True
},
}