如何显示非表返回查询的控制台输出?
例如
Vector row = (Vector) data.elementAt(0);
我在MS SQL Server Management Studio上收到以下错误消息,但不确定如何在带有w / pyodbc的python中看到它。
conn = pyodbc.connect('Driver={SQL Server Native Client 12.0};Server=...')
conn.autocommit = True
cursor = conn.cursor()
sql = """
ALTER DATABASE XXXX
SET OFFLINE WITH ROLLBACK IMMEDIATE
RESTORE DATABASE XXXX
FROM DISK = '\\path\to\file\XXXX.bak'
"""
cursor.execute(sql)
但是Pyodbc的运行没有引发任何异常,并且很正常。
打印光标对象仅返回光标对象,而Msg 3201, Level 16, State 2, Line 4
Cannot open backup device '\\path\to\file\XXXX.bak'. Operating system error 5(Access is denied.).
Msg 3013, Level 16, State 1, Line 4
RESTORE DATABASE is terminating abnormally.
仅适用于结果查询。