The problem, in this case is the connection string:
DATABASES = {
# Microsoft SQL Server version
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'foo',
'USER': 'blah',
'PASSWORD': 'password',
'HOST': '0.0.0.0',
'PORT': '1433',
'OPTIONS': {
'driver': 'FreeTDS',
},
},
}
Should be
DATABASES = {
# Microsoft SQL Server version
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'foo',
'USER': 'bar',
'PASSWORD': 'password',
'HOST': '0.0.0.0',
'PORT': '1433',
'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
},
},
}
FreeTDS was the problem. I do not know why, but eliminating it from the chain fixed the problem.
manpreet
Best Answer
2 years ago
I am assuming this is NOT a common scenario -- however I am running Django 2.0.9, pyodbc 4.0.24, django-pyodbc-azure 2.0.4.1 and ODBC 17 on my Mac, talking to SQL Server running in Docker, Microsoft SQL Server 2017.
For reasons also beyond my control, I am modeling a system where uploads are stored a BLOBs, varbinary types in SQL Server parlance.
No matter what I do, as soon as I declare a BLOB type and attempt to load a fixture (without a BLOB) I get the error:
Could not load mytype.MyType(pk=3455): ('22018', '[22018] [FreeTDS][SQL Server]Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query. (257) (SQLExecDirectW)')
The model is as follows:
I loaddata using a fixture with everything BUT the syllabus and I always get there error:
Problem installing fixture '/path/to/fixtures/0011_mydata.json': Could not load mytype.MyType(pk=3455): ('22018', '[22018] [FreeTDS][SQL Server]Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query. (257) (SQLExecDirectW)')
I believe the error is a red herring, the real problem lies in a driver specific to Mac <-> Sql Server in Docker
Any help is appreciated!