Тема: MsSql + Python3.4 + Django 1.8
Доброго дня шановна спільното
Пробую підключитися до бази на MSSQL Express 2014
:
DATABASES = {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'default': {
'NAME': 'trade',
'ENGINE': 'sqlserver_ado',
'HOST': 'DESKTOP-GF2P2S4\SQLEXPRESS',
'USER': '',
'PASSWORD': '',
'OPTIONS': {
'provider':'SQLOLEDB',
'use_legacy_date_fields': 'True'
}
}
}
не виходить.
результат із IDLE:
>>>
>>> import sqlserver_ado
>>> from django.db import connection
>>> cursor = connection.cursor()
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
cursor = connection.cursor()
File "C:\Python34\lib\site-packages\django\db\__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Python34\lib\site-packages\django\db\utils.py", line 237, in __getitem__
self.ensure_defaults(alias)
File "C:\Python34\lib\site-packages\django\db\utils.py", line 168, in ensure_defaults
conn = self.databases[alias]
File "C:\Python34\lib\site-packages\django\utils\functional.py", line 59, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Python34\lib\site-packages\django\db\utils.py", line 151, in databases
self._databases = settings.DATABASES
File "C:\Python34\lib\site-packages\django\conf\__init__.py", line 48, in __getattr__
self._setup(name)
File "C:\Python34\lib\site-packages\django\conf\__init__.py", line 42, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
>>>
Дякую за допомогу.