Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Execute DBCC CHECKDB from python script
I have to run this query from inside the python script using pyodbc (python 3):

In code I have the following:

query = '''
resultSet = curs.fetchall()
I've got the error: resultSet = curs.fetchall() pyodbc.ProgrammingError: No results. Previous SQL was not a query.

Note: In case I have any 'select ..' query it works fine. It looks to me that pyodbc can't handle DBCC CHECKDB .. statement

I noticed that when I run this statement from SQL client the output goes into Tab 'Messages' while output from 'select' statements go into Tab 'Result Set'. Sounds that 'output' does not have information from 'Messages'. Maybe query should be modified to get result from 'Messages' or etc.?

Question: how could I run it from inside the python script?

Actually I resolved my issue by adding parameter tableresults


Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Execute full script samuelbachorik 0 213 Aug-06-2020, 08:09 PM
Last Post: samuelbachorik
  How to kill a bash script running as root from a python script? jc_lafleur 4 418 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 338 May-28-2020, 05:27 PM
Last Post: micseydel
  Trying to write and execute first Python script garvind25 3 353 May-23-2020, 07:36 PM
Last Post: garvind25
  Execute script in IDLE with parameters Pavel_47 11 789 Mar-14-2020, 05:41 AM
Last Post: Larz60+
  How to execute Python code leemao 2 375 Dec-21-2019, 02:35 PM
Last Post: leemao
  How to write a script to execute a program need passing additional input? larkypython 2 541 Nov-23-2019, 04:38 AM
Last Post: larkypython
  Execute .sql file in python pradeepkumarbe 3 6,149 Nov-05-2019, 08:55 AM
Last Post: MckJohan
  Pyinstaller with Sys.Argv[] - “Failed to Execute Script”? ironfelix717 0 1,176 Aug-07-2019, 02:29 PM
Last Post: ironfelix717
  Help with PyInstaller + Script "Failed to Execute Script" ironfelix717 2 5,695 Jul-31-2019, 02:18 PM
Last Post: ironfelix717

Forum Jump:

Users browsing this thread: 1 Guest(s)