dbcli / mycli

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
http://mycli.net
Other
11.39k stars 657 forks source link

Autocompletion errors when connecting to MemSQL #279

Open kkdd opened 8 years ago

kkdd commented 8 years ago

mycli seems to work with memsql. The following error, however, displayed at launching:

$ mycli -u root -h 127.0.0.1 -P 3306 -D memsql
Version: 1.7.0
Chat: https://gitter.im/dbcli/mycli
Mail: https://groups.google.com/forum/#!forum/mycli-users
Home: http://mycli.net
Thanks to the contributor - Whitane Tech
mysql root@127.0.0.1:memsql> Exception in thread completion_refresh:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/t
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/t
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/Cellar/mycli/1.7.0/libexec/lib/python2.7/site-packages/mycli/
    refresher(completer, executor)
  File "/usr/local/Cellar/mycli/1.7.0/libexec/lib/python2.7/site-packages/mycli/
    completer.extend_users(executor.users())
  File "/usr/local/Cellar/mycli/1.7.0/libexec/lib/python2.7/site-packages/mycli/
    for user in users:
  File "/usr/local/Cellar/mycli/1.7.0/libexec/lib/python2.7/site-packages/mycli/
    cur.execute(self.users_query)
  File "/usr/local/Cellar/mycli/1.7.0/libexec/vendor/lib/python2.7/site-packages
    result = self._query(query)
  File "/usr/local/Cellar/mycli/1.7.0/libexec/vendor/lib/python2.7/site-packages
    conn.query(q)
  File "/usr/local/Cellar/mycli/1.7.0/libexec/vendor/lib/python2.7/site-packages
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/usr/local/Cellar/mycli/1.7.0/libexec/vendor/lib/python2.7/site-packages
    result.read()
  File "/usr/local/Cellar/mycli/1.7.0/libexec/vendor/lib/python2.7/site-packages
    first_packet = self.connection._read_packet()
  File "/usr/local/Cellar/mycli/1.7.0/libexec/vendor/lib/python2.7/site-packages
    packet.check_error()
  File "/usr/local/Cellar/mycli/1.7.0/libexec/vendor/lib/python2.7/site-packages
    err.raise_mysql_exception(self._data)
  File "/usr/local/Cellar/mycli/1.7.0/libexec/vendor/lib/python2.7/site-packages
    _check_mysql_exception(errinfo)
  File "/usr/local/Cellar/mycli/1.7.0/libexec/vendor/lib/python2.7/site-packages
    raise InternalError(errno, errorvalue)
InternalError: (1049, u"Unknown database 'mysql'")

mysql root@127.0.0.1:memsql> 
Time: 0.000s
mysql root@127.0.0.1:memsql> show databases;
Time: 0.002s
+--------------------+
| Database           |
+--------------------+
| information_schema |
| memsql             |
| sharding           |
+--------------------+
mysql root@127.0.0.1:memsql>                                                    
Goodbye!
$ 
tsroten commented 7 years ago

@kkdd Thanks for letting us know about this.

The problem appears to be the background smart completion queries that hit the database called mysql. Apparently, MemSQL doesn't use this database to store data (e.g. users, etc.).

It seems reasonable for the background completion thread to check if the mysql database exists before trying to query it. If anyone wants to take a look at that, it's in sqlexecute.py and completion_refresher.py.