MSSQL2008 - Pyodbc - Previous SQL was not a query

前端 未结 8 1389
我寻月下人不归
我寻月下人不归 2020-12-05 04:13

I can\'t figure out what\'s wrong with the following code, The syntax IS ok (checked with SQL Management Studio), i have access as i should so that works too.. but for some

相关标签:
8条回答
  • 2020-12-05 05:02

    I have solved this problem by splitting the use database and sql query into two execute statements.

    0 讨论(0)
  • 2020-12-05 05:04

    First off:

    if you're running a Windows SQL Server 2008, use the "Native Client" that is included with the installation of the SQL software (it gets installed with the database and Toolkits so you need to install the SQL Management applicaton from Microsoft)

    Secondly: Use "Trusted_Connection=yes" in your SQL connection statement:

    cnxn = pyodbc.connect('DRIVER={SQL Server Native Client 10.0};SERVER=ServerAddress;DATABASE=my_db;Trusted_Connection=yes')
    

    This should do the trick!

    0 讨论(0)
提交回复
热议问题