How should I unit test MySQL queries?
问题 I'm building some unit tests for my Python module which interfaces with a MySQL database via SQLAlchemy. From reading around I gather the best way to do this is to create a test database that I can query as if it was the real thing. I've done this however how should I test the existing queries in the module as they currently all point at the live database? The only idea I'd come up with was to do something like the following: def run_query(engine, db_name='live_db') engine.execute(f'SELECT *