Open godhelpjun opened 5 years ago
Hi @godhelpjun! Thanks for reporting this. It does appear that the reconnect command in mycli is reconnecting through kind of an indirect means. I think we can try to improve on that a little bit.
As a workaround, instead of trying to reconnect, if you simply try to execute a query, mycli should automatically try to reconnect. In my experience that tends to be faster. It looks like this:
mycli> select * from users limit 5;
Reconnecting...
After it reconnects, you will either get the output of the query, or a message letting you know that the reconnection attempt failed.
A note for changing the reconnect
command. In the MySQL client, running the reconnect command actually gets a new connection ID. In mycli, it is a synonym for the use
command.
We should make the reconnect command actually try to connect to the database again. Here is the logic we use to automatically reconnect to the database: https://github.com/dbcli/mycli/blob/master/mycli/main.py#L662-L667
I also meet this problem.
@tsroten When I execute a query when mycli command line is idle for long time, reconnect is also slow,about 8 seconds even more.
when mycli command line is idle for long time,then the connection is lost.When I try to reconnect using command \r mydb it takes time so long to wait for displaying reconnecting .... once I see the Reconnecting..... displayed It connect to server so fast. so,I wonder why it take me so long to wait,even slower a new command line " mycli -hhost -ppass -uroot "