I am trying to get sql server data and log path using SERVERPROPERTY.
When I run below stmt in SSMS, I get paths.
SELECT SERVERPROPERTY('InstanceDefaultLogPath') ,SERVERPROPERTY('InstanceDefaultDataPath')
But when I try to run the same query from python using pyodbc. it gives me:
result = connsql.cursor().execute(query).fetchone()
pyodbc.ProgrammingError: ('ODBC SQL type -150 is not yet supported. column-index=0 type=-150', 'HY106')
Any idea how to get the paths in python?
Code:
def getSQLServerPath(self):
try:
print("Into function..")
connsql = self.sql_connection()
query = "SELECT SERVERPROPERTY('InstanceDefaultLogPath') ,SERVERPROPERTY('InstanceDefaultDataPath') "
result = connsql.cursor().execute(query).fetchone()
print(result)
connsql.cursor().commit()
connsql.close()
# return path
except Exception:
logging.exception("getSQLServerPath function: Something went wrong.")