CLN: clean sqlalchemy import
xref #40686

thanks @fangchenli very nice as always! Just a note: this broke our tests where we were passing a mock in as a SQLite conn, which with this change leads to the SQLAlchemy import being attempted. Worked around by setting `conn_mock.__class__ = sqlite3.Connection` to fool the `isinstance()` check.