ImproperlyConfigured: MySQL driver not installed
You may refer to MySQL API Dependency Installation to install the MySQL Drivers.
This issue is stated at ImproperlyConfigured: MySQL driver not installed! · Issue #1569 · coleifer/peewee
Authentication plugin ‘caching_sha2_password’ cannot be loaded
One way to solve this is to login to the database and change the password to legacy mode for the particular user, for example
alter user 'username'@'%' identified with mysql_native_password by 'your_password';
This should properly solve the problem.
%
means remote user, it can be replaced bylocalhost
for local users.
pymysql.err.InterfaceError: (0, ”) or peewee.OperationalError: (2006, ‘MySQL server has gone away’)
If you are using the pymysql
API, it will be pymysql.err.InterfaceError: (0, '')
, or if you are using mysqlclient
, it’s peewee.OperationalError: (2006, 'MySQL server has gone away')
.
The problem happens because the SQL long connection is broken, and peewee
by default manages the connection for you, and it does not reconnect when the connection is broken.
To solve this problem, you may handle all of these connections manually. peewee
does provide mixin
for this purpose.
# init the SQL database db = MySQLDatabase(...) @db.connection_context() def some_sql_operation_utility(): # perform some transaction here
With the connection_context()
method for MySQLDatabase
class as a mixin
, the connection can be re-established and closed explicitly, thus eliminating the issue.