superset data source management (1)

In the default state of superset, the sqlite database is used. Due to sqlite performance problems, it is now necessary to switch to the mysql database;

The first step is to prepare the Mysql database service

schema:superset_db

userName:root

password:root

 

 

The server where superset is located also needs to install mysql-related dependencies

yum install mysql-community-client
yum install mysql-devel

//Install the dependencies of Python to connect to mysql
pip install mysqlclient

 


Step 1: Modify the configuration file ${superset}/config.py

   

vim config.py

 

# The SQLAlchemy connection string.
#SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(DATA_DIR, 'superset.db')
#SQLALCHEMY_DATABASE_URI = 'mysql://myapp@localhost/myapp'
SQLALCHEMY_DATABASE_URI = 'mysql://root:[email protected]/superset_db?charset=UTF8'
Entering Ex mode.  Type "visual" to go to Normal mode.

 


 Step 2: Reinitialize the password

 fabmanager create-admin --app superset

 

Step 3: Initialize the database

superset db upgrade

 

Step 4: Load the examples

superset load_examples

 

Step 4: Initialize superset superset init

 

Step 5: Start the server superset runserver

 

 

 

Superset can support multiple data sources at the same time, and developers can manage data sources through the console

 


   

Then click the "+" in the upper right corner to add a data source

 

Developers can use this data source in the SQL tool of superset only if the option "Open in SQL Toolbox" is checked;

 

The SQLAlchemy URI item needs to enter the correct data source address, for example: mysql://root:[email protected]/superset_test_db?charset=utf8, root is the username, XXXXXXXXXX is the password, superset_test_db is the database schema, and charset=utf8 is specified Data source encoding (very important);

 

Note: After entering the data source uri, click the "Test Connection Button" and return to "Seems OK!" It means the connection is successful, and you can click the Save button!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326066527&siteId=291194637