I have the code below which fails with the message
from sqlalchemy_utils.functions import database_exists, create_database, drop_database
url = f'mssql+pymssql://user:secret_password@db_host/my_database?charset=utf8'
if database_exists(url):
drop_database(url)
create_database(url)
Error:
sqlalchemy.exc.OperationalError: (pymssql.OperationalError) (574, b'DROP DATABASE statement cannot be used inside a user transaction.DB-Lib error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n') E [SQL: DROP DATABASE my_database] E
(Background on this error at: http://sqlalche.me/e/e3q8)
Not sure what I'm doing wrong - examples online show this as valid code. There is no state - I've executed the above in a fresh ipython session.