py 2.6, win, MSSQL 2000
import pyodbc
try:
connection = pyodbc.connect(driver='SQL Server Native Client 10.0',host=nHost,database='',trusted_connection='yes',autocommit=True)
cursor = connection.cursor()
qry = r"""RESTORE DATABASE %s
FROM DISK = '%s'
WITH RECOVERY,
MOVE 'w7_Data' TO 'C:\MSSQL\v7t_tss.mdf',
MOVE 'w7_Log' TO 'C:\MSSQL\v7t_tss_log.ldf',
REPLACE
""" % (nBase,nFileName)
print qry
cursor.execute(qry)
connection.close()
print 'restore ok'
return ''
except Exception as e:
print e
return str(e)