Hi there.
Could you tell me a good way to use Django with Micro Soft DB SQL server. I tried django_pyodbc. Any suggestion is appreciated.
my PC of Environment is below.
Database:
SQL Server 2014 Express
OS:
Windows 7 Home Premium SP1
I used the django module, django_pyodbc.
And, I tried to run syncdb but I couldn't.
My settings.py is below.
DATABASES = {
'default': {
'ENGINE': "django_pyodbc",
'HOST': "localhost",
'USER': "djangouser",
'PASSWORD': "xxxxx",
'NAME': "db_test",
'OPTIONS': {
'host_is_server': True,
'autocommit': True,
'unicode_results': True,
'extra_params': 'tds_version=8.0'
},
}
}
Things I tried and did not work:
1,change "localhost" to "127.0.0.1,1433" in the HOST property of the code.
2,removed 'OPTIONS'.
However, I tried the module pyodbc of pure python like below. It was fine.
---
conn = pyodbc.connect('driver={SQL Server};server=localhost;UID=djangouser;PWD=xxxxx;DATABASE=shannon_test;Trusted_Connection=yes')
---
But, DB connection is not established without "Trusted_Connection=yes".
At least I do not know any other way. Anyone who know this matter, please help.
The error message is here.
----
pyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC SQL Server Driver][
SQL Server]\x82\xb1\x82\xcc\x83\x8d\x83O\x83C\x83\x93\x82\xc5\x97v\x8b\x81\x82\x
b3\x82\xea\x82\xbd\x83f\x81[\x83^\x83x\x81[\x83X "shannon_test" \x82\xf0\x8aJ\x8
2\xaf\x82\xdc\x82\xb9\x82\xf1\x81B\x83\x8d\x83O\x83C\x83\x93\x82\xc9\x8e\xb8\x94
s\x82\xb5\x82\xdc\x82\xb5\x82\xbd\x81B (4060) (SQLDriverConnect); [01S00] [Micro
soft][ODBC SQL Server Driver]\x90\xda\x91\xb1\x95\xb6\x8e\x9a\x97\xf1\x82\xcc\x9
1\xae\x90\xab\x82\xaa\x90\xb3\x82\xb5\x82\xad\x82\xa0\x82\xe8\x82\xdc\x82\xb9\x8
2\xf1\x81B (0); [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]\x82\xb1\
x82\xcc\x83\x8d\x83O\x83C\x83\x93\x82\xc5\x97v\x8b\x81\x82\xb3\x82\xea\x82\xbd\x
83f\x81[\x83^\x83x\x81[\x83X "shannon_test" \x82\xf0\x8aJ\x82\xaf\x82\xdc\x82\xb
9\x82\xf1\x81B\x83\x8d\x83O\x83C\x83\x93\x82\xc9\x8e\xb8\x94s\x82\xb5\x82\xdc\x8
2\xb5\x82\xbd\x81B (4060); [01S00] [Microsoft][ODBC SQL Server Driver]\x90\xda\x
91\xb1\x95\xb6\x8e\x9a\x97\xf1\x82\xcc\x91\xae\x90\xab\x82\xaa\x90\xb3\x82\xb5\x
82\xad\x82\xa0\x82\xe8\x82\xdc\x82\xb9\x82\xf1\x81B (0)')
----