<i id='PUl0e'><tr id='PUl0e'><dt id='PUl0e'><q id='PUl0e'><span id='PUl0e'><b id='PUl0e'><form id='PUl0e'><ins id='PUl0e'></ins><ul id='PUl0e'></ul><sub id='PUl0e'></sub></form><legend id='PUl0e'></legend><bdo id='PUl0e'><pre id='PUl0e'><center id='PUl0e'></center></pre></bdo></b><th id='PUl0e'></th></span></q></dt></tr></i><div id='PUl0e'><tfoot id='PUl0e'></tfoot><dl id='PUl0e'><fieldset id='PUl0e'></fieldset></dl></div>
      1. <small id='PUl0e'></small><noframes id='PUl0e'>

        <tfoot id='PUl0e'></tfoot>
          <bdo id='PUl0e'></bdo><ul id='PUl0e'></ul>

        <legend id='PUl0e'><style id='PUl0e'><dir id='PUl0e'><q id='PUl0e'></q></dir></style></legend>

      2. pyodbc 通过 IIS7 连接到 MSSQL 2005 服务器

        pyodbc connection to MSSQL 2005 server via IIS7(pyodbc 通过 IIS7 连接到 MSSQL 2005 服务器)

        <small id='n9mVS'></small><noframes id='n9mVS'>

        <legend id='n9mVS'><style id='n9mVS'><dir id='n9mVS'><q id='n9mVS'></q></dir></style></legend>
          <bdo id='n9mVS'></bdo><ul id='n9mVS'></ul>
            <tfoot id='n9mVS'></tfoot>
              <tbody id='n9mVS'></tbody>
            • <i id='n9mVS'><tr id='n9mVS'><dt id='n9mVS'><q id='n9mVS'><span id='n9mVS'><b id='n9mVS'><form id='n9mVS'><ins id='n9mVS'></ins><ul id='n9mVS'></ul><sub id='n9mVS'></sub></form><legend id='n9mVS'></legend><bdo id='n9mVS'><pre id='n9mVS'><center id='n9mVS'></center></pre></bdo></b><th id='n9mVS'></th></span></q></dt></tr></i><div id='n9mVS'><tfoot id='n9mVS'></tfoot><dl id='n9mVS'><fieldset id='n9mVS'></fieldset></dl></div>

                1. 本文介绍了pyodbc 通过 IIS7 连接到 MSSQL 2005 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经在我的笔记本电脑上安装并配置了 IIS7,并带有一个 python cgi 界面.我可以从 Eclipse 中运行 python 脚本并从数据库中获取我正在寻找的结果.但是当我从网页运行脚本时,我得到一个身份验证错误.似乎连接字符串没有将凭据传递给 SQL 服务器.有什么想法吗?

                  I have IIS7 installed and configured on my laptop and with a python cgi interface. I can run the python script from within Eclipse and get the results I am looking for from the database. But when I run the script from the webpage I get an authentication error. It seems that the connection string is not passing the credentials to the SQL server. Any thoughts?

                  import pyodbc
                  import cgi
                  import cgitb; cgitb.enable()
                  
                  cnxn = pyodbc.connect(driver='{SQL Server}', 
                                    server='SERVERINSTANCE', 
                                    Trusted_Connection='yes', 
                                    database='Test_Chad', 
                                    uid='SERVERusername', 
                                    pwd='password')
                  
                  def getRow():
                      cursor = cnxn.cursor()
                      cursor.execute("select user_id, user_name from users")
                      row = cursor.fetchone()
                      print 'name:', row.user_id     
                      print 'name:', row.user_name
                  
                  getRow()
                  

                  例外:

                  <class 'pyodbc.Error'>: ('28000', "[28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
                  (18456) (SQLDriverConnect); [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. (18456)") 
                  args = ('28000', r"[28000] [Microsoft][ODBC SQL Server Driver][SQL ... for user 'NT AUTHORITYANONYMOUS LOGON'. (18456)") 
                  message = ''
                  

                  推荐答案

                  决定要使用哪种形式的身份验证,数据库或 Windows.不能同时使用.

                  Decide which form of authentication you want to use, database or Windows. You can't use both.

                  如果您想使用 Windows 身份验证,请将您的连接设置更改为以下内容:

                  If you want to use Windows authentication, change your connection setup to the following:

                  cnxn = pyodbc.connect(driver='{SQL Server}', server='SERVERINSTANCE',  
                                        database='Test_Chad', trusted_connection='yes') 
                  

                  通过 Windows 身份验证将 Web 应用程序连接到数据库需要一些其他配置.如果您的 Web 应用程序在 IIS 中使用匿名身份验证,则将使用运行 Web 应用程序的应用程序池的标识来建立数据库连接.这是设置此身份的屏幕截图:

                  Connecting a web application to a database via Windows authentication requires some other configuration. If your web application uses anonymous authentication in IIS, the database connection will be made using the identity of the application pool in which the web app runs. Here is a screenshot of where this identity is set:

                  如果您想使用简单的数据库身份验证,请为 uidpwd 提供适当的值,并删除 Trusted_Connection=yes::p>

                  If you want to use simple database authentication, provide the appropriate values for uid and pwd, and remove Trusted_Connection=yes:

                  cnxn = pyodbc.connect(driver='{SQL Server}', server='SERVERINSTANCE',  
                                        database='Test_Chad', uid='username', pwd='password')
                  

                  这篇关于pyodbc 通过 IIS7 连接到 MSSQL 2005 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What happens when you compare 2 pandas Series(当你比较 2 个 pandas 系列时会发生什么)
                  Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
                  Python - Compare 2 files and output differences(Python - 比较 2 个文件和输出差异)
                  Why do comparisions between very large float values fail in python?(为什么在 python 中非常大的浮点值之间的比较会失败?)
                  Dictionary merge by updating but not overwriting if value exists(字典通过更新合并,但如果值存在则不覆盖)
                  Find entries of one text file in another file in python(在python中的另一个文件中查找一个文本文件的条目)

                    <small id='Mifqz'></small><noframes id='Mifqz'>

                    <legend id='Mifqz'><style id='Mifqz'><dir id='Mifqz'><q id='Mifqz'></q></dir></style></legend>

                      <tbody id='Mifqz'></tbody>

                          <bdo id='Mifqz'></bdo><ul id='Mifqz'></ul>
                          <i id='Mifqz'><tr id='Mifqz'><dt id='Mifqz'><q id='Mifqz'><span id='Mifqz'><b id='Mifqz'><form id='Mifqz'><ins id='Mifqz'></ins><ul id='Mifqz'></ul><sub id='Mifqz'></sub></form><legend id='Mifqz'></legend><bdo id='Mifqz'><pre id='Mifqz'><center id='Mifqz'></center></pre></bdo></b><th id='Mifqz'></th></span></q></dt></tr></i><div id='Mifqz'><tfoot id='Mifqz'></tfoot><dl id='Mifqz'><fieldset id='Mifqz'></fieldset></dl></div>
                          • <tfoot id='Mifqz'></tfoot>