使用pyodbc将syncdb Django应用程序转换到Azure SQL时出错 [英] Error with syncdb Django app to Azure SQL using pyodbc

查看:37
本文介绍了使用pyodbc将syncdb Django应用程序转换到Azure SQL时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让我的Django应用程序在Azure上运行.我已经启动了该应用程序并在其中运行了一些静态页面,但是无法正常运行数据库.我下载了 pyodbc ,以便Django可以与Azure SQL数据库进行通信,并且将二者都放入在我的本地计算机和Web服务器上.我还升级了Azure网站,使其使用Django-1.6而不是默认的1.4,但是我仍在使用Python 2.7

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

我已经设置了Azure文件墙规则,以允许从我的IP地址进行访问

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

在settings.py中,我像这样设置DATABASES部分:

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,
},

当我尝试从本地计算机运行syncdb时,出现此错误:

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)')

我尝试过重新格式化settings.py,但仍然遇到相同的错误.我尝试将端口号放在Azure门户中显示的主机名之后,并且尝试在USER中使用完整的主机名.

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.

推荐答案

不支持iODBC.但是,支持unixODBC.我能够启动Azure Ubuntu VM,并按照指南以运行syncdb.不太理想,但现在可以使用.

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.

这篇关于使用pyodbc将syncdb Django应用程序转换到Azure SQL时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆