superset icon indicating copy to clipboard operation
superset copied to clipboard

Change the setting of superset from sqlite to MySQL - a problem!

Open burlakabogdan opened this issue 9 years ago • 16 comments

Make sure these boxes are checked before submitting your issue - thank you!

  • [+ ] I have checked the superset logs for python stacktraces and included it here as text if any
  • [+ ] I have reproduced the issue with at least the latest released version of superset
  • [+ ] I have checked the issue tracker for the same issue and I haven't found one similar

Superset version

version: 0.17.1

Hey. I want to change the standard database configuration from sqlite to mysql.

  1. Added its configuration file superset_config.py and put it in PYTHONPATH
# 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://superset:32rasdf356ytsdfDD@localhost/superset'

# Flask-WTF flag for CSRF
CSRF_ENABLED = True

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

  1. I'm executing the code Fabmanager create-admin --app superset

In my database mysql, tables have been added, as well as 1 user admin.

default

  1. Then I execute the code: Superset db upgrade

At this point, the sqlite database is created! Why? default

default

  1. Then I execute the code: Superset init

And the changes are again happening in the database sqlite ! Why? default

Thank you.

burlakabogdan avatar Mar 24 '17 10:03 burlakabogdan

export PYTHONPATH=$WHEREYOURCONFIGIS:$PYTHONPATH

should do the trick, where of course WHEREYOURCONFIGIS is the path of the superset_config with the mysql database.

xrmx avatar Mar 24 '17 19:03 xrmx

I think there is something wrong with the latest (pip) version of superset. I had it working with psql and after a recent deploy that installed the latest superset it stopped working. I rolled back to version 0.15.4 and it works again.

Edit: My config file was in my PYTHONPATH

jasondscott avatar Mar 25 '17 04:03 jasondscott

@jasondscott: you had superset installed on postgresql?

xrmx avatar Mar 25 '17 10:03 xrmx

Anyway superset_config.py work fine here with latest master to override the db, fails badly with the options read by the cli though.

xrmx avatar Mar 25 '17 10:03 xrmx

@xrmx Yes superset is installed on postgresql. Is that a problem?

jasondscott avatar Mar 25 '17 16:03 jasondscott

To debug you can fire up ipython, run import superset_config and type superset_config? and it will print the location of your superset_config module. This needs to happen in the same context/environment as where you start the web server process from.

mistercrunch avatar Mar 25 '17 17:03 mistercrunch

Whatever the problem was I think its been addressed. Closing

mistercrunch avatar May 15 '17 02:05 mistercrunch

@jasondscott is this solved?

I am running superset 0.19.0 and installed it from pip with Python 3.4.5. However, I faced the same issue as this while I am using postgresql.

If it is solved, how did you solve it?

Aung-Myint-Thein avatar Aug 08 '17 07:08 Aung-Myint-Thein

Oh solved the problem by export PYTHONPATH="/home/user/superset/:$PYTHONPATH".

Initially, I was using export PYTHONPATH="/home/user/superset:$PYTHONPATH". .. one simple / solved the problem :)

Aung-Myint-Thein avatar Aug 08 '17 09:08 Aung-Myint-Thein

after removing ~/.superset/superset.db, it works

JazzChen avatar Sep 20 '17 10:09 JazzChen

so that it works for me, change the variable also in the config.py file (/usr/local/lib/pythonX.X/site-packages/config.py)

ricardoorozco avatar Aug 14 '18 19:08 ricardoorozco

export SUPERSET_CONFIG_PATH=superset/superset_config.py work for me

bllli avatar Mar 15 '19 05:03 bllli

It seems that when i use Python 3.6.6 and try to add mysql instead of sqlite i get error : Was unable to import superset Error: No module named 'MySQLdb'. There is no MySQLdb for python 3+.Has Anyone faced this issue?

rashmigulhane avatar May 08 '19 11:05 rashmigulhane

bump

tooptoop4 avatar Jun 11 '19 19:06 tooptoop4

export SUPERSET_CONFIG_PATH=superset/superset_config.py

worked for me thanks!

ccggeo avatar Jun 27 '19 14:06 ccggeo

export SUPERSET_CONFIG_PATH=superset/superset_config.py work for me

This worked for me today (Oct 2023), more than 6 years after the issue was reported. I had to change the path to /app/pythonpath/superset_config.py because the folder structure has changed (obviously).

I did not find this anywhere in the documentation either. Took me WEEKS to figure this tiny thing out!

pundalikvk avatar Oct 04 '23 16:10 pundalikvk