Search code examples
pythonmysqlsqliteflaskapache-superset

Configuring apache superset with mysql database


I am configuring apache to read from mysql instead of sqlite; The following is the details in my configuration file. I don't quite understand how to configure the file above to read from my database so that i can begin creating summaries: I have referred to this documentation for my set up. https://superset.incubator.apache.org/installation.html

# Superset specific config
#---------------------------------------------------------
ROW_LIMIT = 200000
SUPERSET_WORKERS = 4

SUPERSET_WEBSERVER_PORT = 8088
#---------------------------------------------------------

#---------------------------------------------------------
# Flask App Builder configuration
#---------------------------------------------------------
# Your App secret key
SECRET_KEY = '\2\1t567fgj7dtghjdhfui64@#$&77cvw424tkey\1\2\e\y\y\h'

# The SQLAlchemy connection string to your database backend
# This connection defines the path to the database that stores your
# superset metadata (slices, connections, tables, dashboards, ...).
# Note that the connection information to connect to the datasources
# you want to explore are managed directly in the web UI
#SQLALCHEMY_DATABASE_URI = 'sqlite:////path/to/superset.db'
SQLALCHEMY_DATABASE_URI = 'mysql://username:password@localhost:3307/'

# Flask-WTF flag for CSRF
CSRF_ENABLED = True

# Set this API key to enable Mapbox visualizations
MAPBOX_API_KEY = ''

I run the following command to init my project

superset init

This results to the following error:

ERROR:flask_appbuilder.security.sqla.manager:DB Creation and initialization failed: 'NoneType' object has no attribute 'replace'

Any direction to fix my configuration issue will be highly appreciated


Solution

  • There might be 2 things going on:

    1. It seems your DB URI should be in the format of mysql://username:password@host:port/dbname as opposed to just mysql://username:password@host:port/ (see https://docs.sqlalchemy.org/en/13/core/engines.html#mysql for reference)
    2. It seems you're looking to connect to that mysql database in order to query it and visualize its data - NOT to use it as your superset database backend (i.e. the database superset is going to use in order to persist your superset configurations). For the latter, you might be better off to just using sqlite.
      In order to connect to your target DB to actually query it, see "Connecting To Your Target Database(s)" on https://duperset.com/getting_started