【问题标题】:Django-REST: The database driver doesn't support modern datatime typesDjango-REST:数据库驱动程序不支持现代数据时间类型
【发布时间】:2019-11-29 23:26:07
【问题描述】:

我正在尝试在 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

【问题讨论】:

    标签: django django-rest-framework odbc freetds


    【解决方案1】:

    问题在于您的 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 版本更新得多。

    祝你好运!

    【讨论】:

    • 更新:freetds-bin 已经是最新版本(0.91-6.1+b4)。 freetds-dev 已经是最新版本(0.91-6.1+b4)。 tdsodbc 已经是最新版本(0.91-6.1+b4)。到较新的版本并将 FreeTDS 设置为 versin 7,4 解决了这个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-03
    • 2016-11-22
    相关资源
    最近更新 更多