I\'m trying to write a dataframe to a MySQL table but am getting a (111 Connection refused)
error.
I followed the accepted answer here: Writing to MySQL dat
Thanks to a tip from @AndyHayden, this answer was the trick. Basically replacing mysqlconnector
with mysqldb
was the linchpin.
engine = create_engine('mysql+mysqldb://[user]:[pass]@[host]:[port]/[schema]', echo = False)
df.to_sql(name = 'my_table', con = engine, if_exists = 'append', index = False)
Where [schema]
is the database name, and in my particular case, :[port]
is omitted with [host]
being localhost
.