Error with syncdb Django app to Azure SQL using pyodbc

回眸只為那壹抹淺笑 提交于 2019-12-08 12:56:32

问题


I am trying to get my Django app running on Azure. I had the app up and running with some static pages, but I can't get the database working properly. I downloaded pyodbc so Django can talk to the Azure SQL database, and put it both on my local machine and the web server. I also upgraded the Azure Website to use Django-1.6 instead of the default 1.4, but I am still using Python 2.7

I have already set up Azure filewall rules to allow access from my ip address

In settings.py, I set up the DATABASES section like so:

'ENGINE': 'sql_server.pyodbc',
'NAME': 'django-sql',         
'USER': '<username>@<server>',
'PASSWORD': '<password>',
'HOST': '<server>.database.windows.net',
'PORT': '1433',            
'OPTIONS': {
    'driver': 'SQL Server Native Client 11.0',
    'MARS_Connection': True,
},

When I try to run syncdb from my local machine I get this error:

django.db.utils.Error: ('00000', '[00000] [iODBC][Driver Manager]dlopen({SQL Server Native Client 11.0}, 6): image not found (0) (SQLDriverConnect)')

I have tried reformulating settings.py a bit, and still get the same error. I tried putting the PORT number after the HOST name as it is shown in the Azure Portal, and I have tried using the full HOST name in USER.


回答1:


Looks like iODBC is not supported. unixODBC, however, is supported. I was able to spin up an Azure Ubuntu VM and followed this guide in order to run syncdb. Not ideal but it'll work for now.



来源:https://stackoverflow.com/questions/20666043/error-with-syncdb-django-app-to-azure-sql-using-pyodbc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!