('42S02',“[42S02] [Microsoft] [SQL Server的ODBC驱动程序13] [SQL Server]无效的对象名称'app_poll'。(208)(SQLExecDirectW)”)

时间:2017-12-22 13:24:14

标签: sql-server django django-models azure-sql-database

我在azure web app上运行python django app(使用python-odbc-azure lib)时得到了关注。

    ProgrammingError at /

     ('42S02', "[42S02] [Microsoft][ODBC Driver 13 for SQL Server][SQL 
     Server]Invalid object name 'app_poll'. (208) (SQLExecDirectW)")

       Method:  GET
       Request URL:     http://retailgenieredsky.azurewebsites.net/
       Django Version:  1.11
       Exception Type:  ProgrammingError
       Exception Value:     

       ('42S02', "[42S02] [Microsoft][ODBC Driver 13 for SQL Server][SQL 
       Server]Invalid object name 'app_poll'. (208) (SQLExecDirectW)")

       Exception Location:  D:\home\python354x64\lib\site-
       packages\sql_server\pyodbc\base.py in execute, line 545
       Python Executable:   D:\home\python354x64\python.exe
       Python Version:  3.5.4
       Python Path:     

       ['.',
       'D:\\home\\python354x64\\python35.zip',


     'D:\\home\\python354x64\\DLLs',
     'D:\\home\\python354x64\\lib',
     'D:\\home\\python354x64',
     'D:\\home\\python354x64\\lib\\site-packages',
     'D:\\home\\site\\wwwroot']

    Server time:    Fri, 22 Dec 2017 13:10:47 +0000
    Error during template rendering

    In template D:\home\site\wwwroot\app\templates\app\layout.html, error at line 5
    42S02
    1   <!DOCTYPE html>
    2   <html>
    3   <head>
    4       <meta charset="utf-8" />
    5       <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6       <title>{{ title }} - Django Polls</title>
    7       {% load staticfiles %}
    8       <link rel="stylesheet" type="text/css" href="{% static 'app/content/bootstrap.min.css' %}" />
    9       <link rel="stylesheet" type="text/css" href="{% static 'app/content/site.css' %}" />
    10      <script src="{% static 'app/scripts/modernizr-2.6.2.js' %}"></script>
    11  </head>
    12  
    13  <body>
    14      <div class="navbar navbar-inverse navbar-fixed-top">
    15    <div



 class="container">

我尝试了以下方法。 1.删​​除

5

但下一行给出了同样的错误。

  1. 我尝试删除layout.html,但仍然会给出相同的错误
  2. 这是更深层次的例外。

    chunked_fetch   
    
    False
    
    cursor  
    
    <django.db.backends.utils.CursorDebugWrapper object at 0x00000064038E4F28>
    
    params  
    
    ()
    
    result_type     
    
    'multi'
    
    self    
    
    <sql_server.pyodbc.compiler.SQLCompiler object at 0x00000064038E4668>
    
    sql     
    
    ('SELECT TOP 5 [app_poll].[id], [app_poll].[text], [app_poll].[pub_date] FROM '
     '[app_poll] ORDER BY [app_poll].[pub_date] DESC')
    

    似乎这段代码能够连接mssql数据库,但它无法获取数据。我的理解是对的吗?

    我也是django,mssql和azure的初学者。任何领导都非常感谢。

    由于

1 个答案:

答案 0 :(得分:0)

异常是因为azure sql server没有创建表。因此需要数据库迁移才能在azure上创建表来解决此问题。