Reputation: 1075
I'm trying to get a connection object while using the MySqlHook. Assume I saved a mysql connection in the webserver admin called test_connection
. What I've done:
mysql_hook = MySqlHook(conn_name_attr = 'test_connection')
conn = mysql_hook.get_conn()
Gives me an error: tuple' object has no attribute 'get_conn'
Any help would be very appreciated!
Upvotes: 2
Views: 5640
Reputation: 8239
I am not sure where that code example comes from, especially the parameter conn_name_attr
. It seems that the parameter is wrong.
After looking into the models and the hook itself, it seems to be
MySqlHook(mysql_conn_id='test_connection')
Also, if you get back a tuple try printing it since there might be an error message or other helpful information inside it.
Upvotes: 5