django - Django-REST:数据库驱动程序不支持现代数据时间类型
问题描述
我正在尝试在 Debian 上使用 Django Rest 创建一个 rest API,但是当我运行命令“python3 manage.py migrate”时会抛出这个异常
错误:数据库驱动程序不支持现代数据时间类型。”)django.core.exceptions.ImproperlyConfigured:数据库驱动程序不支持现代数据时间类型。
已安装:
msodbcsql17 is already the newest version (17.3.1.1-1).
freetds-bin is already the newest version (0.91-6.1+b4).
freetds-dev is already the newest version (0.91-6.1+b4).
tdsodbc is already the newest version (0.91-6.1+b4).
unixodbc-dev is already the newest version (2.3.7).
unixodbc is already the newest version (2.3.7).
文件:odbc.ini
[MYSERVER]
Description = Django SQLServer
Driver = FreeTDS
Trace = Yes
TraceFile = /tmp/sql.log
Database = DjangoDB
Servername = MYSERVER
UserName = sa
Password = *******
Port = 1433
Protocol = 8.0
文件:odbcinst.ini
[FreeTDS]
Description=FreeTDS Driver for Linux & MSSQL on Win32
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup =/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
UsageCount=1
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.3.so.1.1
UsageCount=1
文件:freetds.conf
[global]
# TDS protocol version
tds version = 8.0
[MYSERVER]
host = localhost
port = 1433
tds version = 8.0
解决方案
问题在于您的 TDS 版本。8.0 版实际上并不是一个有效的版本,尽管 Internet 上存在很多不好的建议。这有很多原因,但 8.0 版实际上映射到 TDS 7.1 版,这是在 Microsoft 在 SQL Server 2008 中添加新的日期和时间字段类型之前。请参阅此处的脚注:
https://www.freetds.org/userguide/tdshistory.htm
您正在运行一个相当旧版本的 FreeTDS (0.91)。它仅支持 SQL Server 2005 中引入的 TDS 版本 7.2。我建议升级您的 FreeTDS 版本,并使用 TDS 版本 7.3。详情在这里:
https://www.freetds.org/userguide/choosingtdsprotocol.htm
另一种选择是使用您似乎已经安装的 MS ODBC 驱动程序,它比您拥有的 FreeTDS 版本更新得多。
祝你好运!
推荐阅读
- r - 删除R中重复的分号?
- python - 如何从壁虎中检索“infeasibilities.txt”
- vulkan - Vulkan:将 3 通道图像上传到设备
- sql-server - SSIS 包在 SQL Server 上运行时无法访问目录
- freemarker - Freemarker - 检查列表是否仅包含空字符串
- c# - CastleWindsor LifestylePerWebRequest 不起作用
- r - 非零值的分组和计算平均值
- c# - 分发 ASP.NET MVC 应用程序
- javascript - Javascript 调试问题:“未捕获的 ReferenceError:未定义画布”
- arduino - 检索在 Thingsboard 中发布的传感器数据时 MQTT 的正确语法