Reputation: 6835
def get_engine():
engine = create_engine('mysql+mysqlconnector://...my_conn_string...', echo=True)
return engine
def generic_execute(sql):
db = get_engine()
connection = db.connect()
connection.execute(sql)
The code above executes the query properly but appears to hang infinitely.
How does one properly "close" or "kill" this connection? Thank you very much!
Upvotes: 2
Views: 6875
Reputation: 3026
As you said the connection needs to be closed as stated by the documentation.
So after you are done executing the sql query you need to call:
connection.close()
Also if you are done with the engine db
you can call db.dispose()
to clean everything.
Upvotes: 2