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

DBCC CHECKDB ('database_name') WITH ESTIMATEONLY
In code I have the following:

query = '''
DBCC CHECKDB ('database_name') WITH ESTIMATEONLY
'''
curs.execute(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?

Thanks
Reply
#2
Actually I resolved my issue by adding parameter tableresults

Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Locally run an APK and execute functions using Python KovyJ 0 442 Jan-23-2025, 05:21 PM
Last Post: KovyJ
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 8,028 Jun-29-2023, 11:57 AM
Last Post: gologica
  How To Set Up And Execute A Python File knight2000 4 4,088 May-31-2022, 10:02 AM
Last Post: Larz60+
  execute python script guy7200 1 2,158 Oct-25-2021, 09:55 PM
Last Post: Axel_Erfurt
  Possible to execute a python script before log off/shutdown with input commands? Kaltex 1 3,120 May-18-2021, 06:31 AM
Last Post: Skaperen
  Using python to execute app or cmd that requires admin credentials thewolf 0 2,702 Mar-05-2021, 08:15 PM
Last Post: thewolf
  Execute full script samuelbachorik 0 2,001 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 7,960 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,967 May-28-2020, 05:27 PM
Last Post: micseydel
  Trying to write and execute first Python script garvind25 3 3,730 May-23-2020, 07:36 PM
Last Post: garvind25

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020