Django 连接(sqlserver)数据库方法

文章目录

Django只内置了几个 Database Backend(mysql、oracle、sqllite3(默认)、postgresql_psycopg2),所以原生并不支持Microsoft SQL Server

django 的SQL server适配器,例如django-pyodbc-azure 或 mssql-django

1、django-pyodbc-azure

2、mssql-django


具体的选择根据自己python 和 django 的版本决定

3、注意

如果使用mssql引擎 启动项目时报错

python 复制代码
django.core.exceptions.ImproperlyConfigured: 'mssql' isn't an available database backend or couldn't be imported. Check the above exception. To use one of the built-in
backends, use 'django.db.backends.XXX', where XXX is one of:
    'mysql', 'oracle', 'postgresql', 'sqlite3'

需注意自己安装的版本是否正确

亲测有效

python 复制代码
python 3.8
django 4.2.14
pyodbc==5.2.0
mssql-django==1.5
python 复制代码
python 3.8
Django==3.2.25
pymssql==2.3.1
pyodbc==5.1.0
相关推荐
ego.iblacat2 分钟前
MySQL 高可用
数据库·mysql·adb
阿里小阿希7 分钟前
PostgreSQL 判断大导入是否正在执行 pg_stat_activity
数据库·postgresql
xrui5810 分钟前
PostgreSQL异常:An IO error occurred while sending to the backend
数据库·postgresql
卢傢蕊30 分钟前
PostgreSQL 初体验
数据库·postgresql
softshow102632 分钟前
PostgreSQL 12 完整部署+迁移+数据恢复
数据库·postgresql
bearpping35 分钟前
关于Mysql 中 Row size too large (> 8126) 错误的解决和理解
数据库·mysql
zhuiyisuifeng35 分钟前
PostgreSQL_安装部署
数据库·postgresql
watersink37 分钟前
第15章 数据库系统
数据库
一只专注api接口开发的技术猿1 小时前
商品详情API的SLA保障体系:监控告警、异常检测与自动化修复
运维·数据库·架构·自动化
WarPigs1 小时前
SQL Server笔记
服务器·数据库·sqlserver