Skip to content

[bug] Database is not set after a reconnect #1437

@scottnemes

Description

@scottnemes

Currently when your connection is lost and a reconnect occurs, mycli thinks you are still connected to a database, while the connection itself does not:

MySQL scottn@localhost:(none)> use dev;
You are now connected to database "dev" as user "scottn"
Time: 0.001s
MySQL scottn@localhost:dev> select * from t2;
+----+
| id |
+----+
| 2  |
| 2  |
+----+

2 rows in set
Time: 0.004s
MySQL scottn@localhost:dev> select * from t2;
Reconnecting...
Reconnected successfully.
Any session state was reset.
(1046, 'No database selected')
MySQL scottn@localhost:dev>

This should be fixable by using the connection.select_db() method after the connection.ping(reconnect=True) is sent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions