Django uses QSL server database

1.Django: Installation and Learning Officer Network https://docs.djangoproject.com/en/2.1/

2. Use the database: (SQL server2012)

Django uses SQL server database cmd need to install the software:

pip install django-pyodbc-azure

And set using SQL server 2012 database in Django project.

Modify the project settings.py

DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'myTestDB',
        'USER': '数据库登录名',
        'PASSWORD': '数据库登录密码',
        'HOST': 'localhost',
        'PORT': '',
        'OPTIONS': {
            'driver': 'SQL Server Native Client 11.0',
        },
    }
}

Ensure that the database exists, the connection password is correct name, wherein the 'driver' is a value corresponding to the control panel - Add> - Tools> Management - -> System and Security> data source (the ODBC) -> System DSN    

Restart the server and successfully connect SQL server 2012 database to success: python manage.py runserver

Guess you like

Origin blog.csdn.net/qq_23903863/article/details/82594390