Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'NoneType' object has no attribute 'replace' #102

Closed
programagor opened this issue Oct 29, 2019 · 2 comments
Closed

'NoneType' object has no attribute 'replace' #102

programagor opened this issue Oct 29, 2019 · 2 comments

Comments

@programagor
Copy link

programagor commented Oct 29, 2019

Greetings

I'm using Docker for MySQL and Jupyter, and am having difficulties using this extension. I can see the SQL icon and run it, but when I enter my username, password, and database hostname, the only thing I see is 'NoneType' object has no attribute 'replace'.

Here are the relevant parts of my docker-compose:

version: "3.0"
services:
  db:
    restart: always
    image: "mariadb"
    volumes:
      - ./db/data:/var/lib/mysql
    networks:
      - db_net
  jupyter:
    restart: always
    build: ./py
    networks:
      - db_net
      - web_internal

Here is an excerpt from my Jupyterlab Dockerfile:

FROM jupyterhub/jupyterhub

RUN pip install --upgrade pip

RUN conda install jupyterlab
RUN jupyter labextension install @jupyterlab/hub-extension

RUN pip install jupyterlab_sql pip mysqlclient
RUN jupyter serverextension enable jupyterlab_sql --py --sys-prefix
RUN jupyter lab build

Versions: Jupyterlab 1.1.4, Python 3.6.9, IPython 7.8.0

@pbugnion
Copy link
Owner

pbugnion commented Dec 27, 2019

Thanks for reporting this, and apologies for the late reply.

I can reproduce this when I put no database name in the connection URL. For instance, for a database running locally, if I write:

mysql://

... in the connection URL, I get the same error. However, if I write:

mysql:///employees

... to connect to an employees database, the plugin works as expected.

Other 'supported' database engines behave correctly:

  • with sqlite, if you just specify sqlite:// as the connection URL, you get an in-memory, nameless database, as expected.
  • with postgres, if you just specify postgres:// as the connection URL, it attempts to connect to a local database with the same name as the current user. If that database doesn't exist, the error message is, correctly, No database called USERNAME.

I'll therefore 'fix' this by catching connection URLs for MySQL with no database and raising an appropriate error.

@pbugnion
Copy link
Owner

pbugnion commented Jan 1, 2020

Fixed by #108 .

@pbugnion pbugnion closed this as completed Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants