I’m trying to restore multiple .bak files however using the RESTORE
command but does not recognize the usage of URL option the error states ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]'URL' is not a recognized RESTORE option. (155) (SQLExecDirectW)")
is there a way I can recover multiple .bak files or a work around for my code?
import pyodbc
import pandas as pd
server = "[REDACTED]"
username = "[REDACTED]"
password = "[REDACTED]"
conn_str = "[REDACTED]"
# Establish connection
conn = pyodbc.connect(conn_str)
conn.autocommit = True
cursor = conn.cursor()
sas_token = '[REDACTED]'
url="https://[REDACTED]/PROD_2009_1round.bak"
url2 = 'https://[REDACTED]/PROD_2009_2round.bak'
# Define restore command using the credential object
restore_command = f"""
RESTORE DATABASE [PROD_2009]
FROM URL = '{url}'
WITH FILE = 1, NOUNLOAD, STATS = 10,
URL = '{url2}',
WITH FILE = 2;
"""
# Execute restore command
cursor.execute(restore_command)
# Close cursor and connection
cursor.close()
conn.close()
Previously I’m using this code snippet for RESTORE
but the error I’m getting is this:
restore_command = f"""
RESTORE DATABASE [PROD_2009]
FROM URL = '{url}', URL = '{url2}';
"""
ProgrammingError: ('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The media loaded on "https:[REDACTED]/PROD_2009_1round.bak" is formatted to support 1 media families, but 2 media families are expected according to the backup device specification. (3231) (SQLExecDirectW)')
You need to sign in to view this answers
Leave feedback about this