Does anyone know how to connect to connect to a SQL Server from SQL Alchemy
and pymssql
specifying Failover Partner
? Trying to follow the SQL Alchemy documentation but cannot find failover option.
How can I add Failover Partner=myfailover;Initial Catalog=mydb
to this code?
from sqlalchemy import create_engine
conn_str = "mssql+pymssql://{user}:{pwd}@{host}/{db}".format(host=SERVER, db=DATABASE, user=USERNAME, pwd=PASSWORD)
engine = create_engine(conn_str)
From the documentation it doesn't support failover in the API.
Instead you could try adding a try and except block.
try:
#connect to first partner
except:
# connect to failover