- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 pandas 和 sqlalchemy,并且希望将 DataFrame 加载到 MySQL 数据库中。我目前正在使用此代码片段:
db_connection = sqlalchemy.create_engine('mysql+mysqlconnector://user:pwd@hostname/db_name')
some_data_ref.to_sql(con=db_connection, name='db_table_name', if_exists='replace')
sqlalchemy
, pandas
在此之前已导入。
我的 MySQL 后端是 8.x,我知道它使用 caching_sha2_password
。如果我使用 mysql.connector.connect
连接到数据库我想使用 mysql_native_password
方法,我知道我应该指定 auth_plugin = mysql_native_password
像这样:
mysql.connector.connect(user=user, password=pw, host=host, database=db, auth_plugin='mysql_native_password')
我的问题:有没有办法强制mysql_native_password
使用 sqlalchemy.create_engine('mysql+mysqlconnector://...)
进行身份验证?
对此的任何建议将不胜感激......
最佳答案
您可以使用connect_args
:
db_connection = sqlalchemy.create_engine(
'mysql+mysqlconnector://user:pwd@hostname/db_name',
connect_args={'auth_plugin': 'mysql_native_password'})
或 URL query :
db_connection = sqlalchemy.create_engine(
'mysql+mysqlconnector://user:pwd@hostname/db_name?auth_plugin=mysql_native_password')
关于python - 如何让 sqlalchemy.create_engine 与 mysqlconnector 使用 mysql_native_password 进行连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57459623/
几年前我制作了一个 WPF 应用程序。直到几周前,它一直运行良好。应用程序和在线 mysql 服务器之间的连接似乎已断开。 这是我收到的错误:使用方法“mysql_native_password”对主
我没有看到任何关于此的内容,但我已经尝试了最长的时间来练习使用 SQL 数据库。我尝试了 MSSQL,但一直很沮丧,所以我尝试了 MySQL,并且更进一步。数据库似乎已启动并正在运行,我什至做了一个查
我一直间歇性地遇到以下错误。 使用方法“mysql_native_password”对用户“root”的主机“127.0.0.1”的身份验证失败,并显示消息:从流中读取失败。 它随时都会飙升,我束手无
尝试使用 Visual Studio 2012 Update 3 中的 Connector/Net C#/WinForms 连接到我的 Web 主机上的 MySQL,但收到以下错误消息: Authen
我的GitHub Action配置的示例: jobs: unit-test: name: Unit Testing runs-on: ubuntu-latest servi
我正在创建一个 ASP.NET 网页,并且在执行插入时,程序给出以下错误: 我的代码是这样的: Imports MySql.Data.MySqlClient Imports MySql.Data
尝试根据以下页面启用常规的基于密码的身份验证: https://mariadb.com/kb/en/library/authentication-plugin-unix-socket/ 该页面建议使用
我正在使用 pandas 和 sqlalchemy,并且希望将 DataFrame 加载到 MySQL 数据库中。我目前正在使用此代码片段: db_connection = sqlalchemy.cr
我正在使用 pandas 和 sqlalchemy,并想将 DataFrame 加载到 MySQL 数据库中。我目前正在使用这个代码片段: db_connection = sqlalchemy.cre
你们能帮我完成论文吗,这是我系统中的一个问题。 MySqlConnection cn2 = new MySqlConnection(cn.ConnectionString); cn2.Open();-
我花了很长时间试图弄清楚以下错误消息的含义以及为什么我无法连接 - 尽管任何其他方法都会成功。 Authentication to host 'x.x.x.x' for user 'product'
我在我的项目中使用代码优先方法。但是,当我尝试使用“更新数据库”命令运行 db-migrations 时,出现空引用异常,当我运行应用程序时,出现以下配置错误:使用方法“mysql_native_pa
我已经创建了一个自定义的 Windows 服务,它基于 mysql 表中的队列来假脱机处理新作业(进程,而不是线程)。 “作业”是数据库密集型应用程序和服务(从现在起我将其称为“管理器”)。 在高容量
我是一名优秀的程序员,十分优秀!