How do I get sqlalchemy.create_engine with mysqlconnector to connect using mysql_native_password?

后端 未结 1 1739
天命终不由人
天命终不由人 2021-01-14 09:33

I\'m working with pandas and sqlalchemy, and would like to load a DataFrame into a MySQL database. I\'m currently using this code snippet:

db_connection = sq         


        
相关标签:
1条回答
  • 2021-01-14 09:52

    You could use connect_args:

    db_connection = sqlalchemy.create_engine(
        'mysql+mysqlconnector://user:pwd@hostname/db_name',
        connect_args={'auth_plugin': 'mysql_native_password'})
    

    or the URL query:

    db_connection = sqlalchemy.create_engine(
        'mysql+mysqlconnector://user:pwd@hostname/db_name?auth_plugin=mysql_native_password')
    
    0 讨论(0)
提交回复
热议问题