'Python 3.9 - Connect to memsql

I am trying to connect to memsql (running as docker container - cluster-in-a-box). I am using Python3.9. Tried with Python 3.8 as well.

Here is the code snippet:

from memsql.common import database

conn = database.connect(host="127.0.0.1", port=3306, user="root")
print(conn.query("show databases"))

When i run this, I am getting the following error:

Traceback (most recent call last):
  File "/Users/ngarg/PycharmProjects/memsqlKafka/startup_try.py", line 3, in <module>
    conn = database.connect(host="127.0.0.1", port=3306, user="root")
  File "/Users/ngarg/Library/Python/3.9/lib/python/site-packages/memsql/common/database.py", line 19, in connect
    return Connection(*args, **kwargs)
  File "/Users/ngarg/Library/Python/3.9/lib/python/site-packages/memsql/common/database.py", line 62, in __init__
    self.reconnect()
  File "/Users/ngarg/Library/Python/3.9/lib/python/site-packages/memsql/common/database.py", line 93, in reconnect
    conn = _mysql.connect(**self._db_args)
TypeError: 'db' is an invalid keyword argument for connect()

Try to google this, but didn’t find anything. I am blocked on this step.Any help is appreciated.



Solution 1:[1]

When you connect from the latest version of Django to SingleStore DB, you might receive the following error message:

django.db.utils.OperationalError: (2012, 'Error in server handshake')

To connect to SingleStore DB, you will need to configure the auth_plugin in the OPTIONS field.

DATABASES = {
  'default': {
    'ENGINE': 'django.db.backends.mysql',
    'HOST': '{HOST}',
    'NAME': '{DBNAME}',
    'USER': '{USERNAME}',
    'PASSWORD' : '{PASSWORD}',
    'PORT': '3306',
    'OPTIONS': {
      'auth_plugin': 'mysql_native_password'
    }
  }
}

https://support.singlestore.com/hc/en-us/articles/360057857552-Connecting-Django-to-SingleStore-DB

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shireesh Kumar