我已经按照 philly 和其他人的各种教程使用 django-mssql-backend 设置 django,但没有运气。我认为连接正常,但是当它试图解析表时,我得到一个无法通过的排序规则错误。我正在运行的规格如下:
- django-mssql-后端:2.8.1
- django: 3.2
- pyodbc:4.0.30
'server':{
'ENGINE': 'sql_server.pyodbc',
'NAME': 'database',
'USER': 'username',
'PASSWORD': 'password',
'HOST': 'hostname of server',
'PORT': '',
'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
'unicode_results': True,
},
}
当我尝试运行迁移类创建器或:
python manage.py inspectdb --database=server
我在输出中收到以下错误:
# 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 'ADObjectMemberships'
# The error was: __new__() missing 1 required positional argument: 'collation'
# Unable to inspect table 'ADObjects'
# The error was: __new__() missing 1 required positional argument: 'collation'
我确信这是可能的,因为我在安装了 django 1.8 并安装了旧的 django-pyodbc-azure 模块的情况下使用了不同的 venv,它连接到表并提取它们的信息。我遇到的最大问题是它停止在数据库中留下约 15 个表,并且无论我做什么来修复它都会引发内存错误。
非常感谢您对这个问题的任何想法或帮助!