In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
1. Preface
This practice is all personal learning, I chose to install Superset under window, and embed the background system practice. Summarize the practice process, and share the practice results with you for your reference. If you have better ideas, you are welcome to leave a message.
two。 Environment ready 2.1 install Python
It is recommended that you install Python 3.4 or above. Python version 2.7 has various coding problems on windows. Https://www.python.org/downloads/release/python-350/
Download Windows x86-64 executable installer. You can use exe's installation package directly, and select and add to the environment variable during installation.
Check: run python-V and pip-V under CMD, respectively. If the command cannot be found, you need to add the installation directory of python to the path environment variable.
2.2 install virtualenv
This step is optional, skip to step 4 if you install it directly. Because Superset requires more components to be installed, it is best to use virtualenv to set up a separate python environment.
When developing Python applications, there is only one version of Python3 installed on the system. All third-party packages will be installed by pip into Python3's site-packages directory.
If we were to develop multiple applications at the same time, they would all share a single Python, which is Python 3 installed on the system. What if application A requires jinja 2.7and application B requires jinja 2.6?
In this case, each application may need to have its own "independent" Python runtime environment. Virtualenv is used to create an "isolated" Python environment for an application.
Installation commands:
Pip install virtualenv
2.3 use virtualenv
First create a d:\ pythonVir directory on disk D.
Then activate:
Cd d:\ pythonVirvirtualenv env// waits for initialization to complete. / / activate: env\ Scripts\ activate
The interface after activation is shown in the following figure. Note that there is a (env) mark on the left side of the command line input, so that our subsequent operations will take effect in env and will not affect the overall pyhton environment.
2.4 install VS2015
Some of the dependent libraries in Superset need to be compiled using microsoft visual C++ 2010.
According to the instructions, you can also install Visual C++ 2015 Build Tools:
Http://landinghub.visualstudio.com/visual-cpp-build-tools
2.5 install sasl
Here is a big pit, I installed superset directly before the installation has been unsuccessful, reported an error (sasl.h can not find).
The solution is to download the corresponding version through http://www.lfd.uci.edu/~gohlke/pythonlibs/#sasl
For example, if we install python version 3.6 and the system is 64-bit, download sasl-0.2.1-cp36-cp36m-win_amd64.whl.
In addition, the solution to the occurrence of "Failed building wheel for xxx" during installation is as follows:
Cause: the corresponding whl file is missing.
Solution: download and install the corresponding whl file.
For example, if "Failed building wheel for python_geohash" appears, download the corresponding python version of the python_geohash file.
I am using the Python3.6 version, then find the python_geohash-0.8.5-cp36-cp36m-win_amd64.whl file to download.
Installation method:
Pip install F:\ python_geohash-0.8.5-cp36-cp36m-win32.whl
3. Install Superset
1) after the front environment is ready, begin to install superset.
Pip install superset
Execute the successful interface:
2) create an administrator account:
Fabmanager create-admin-app superset
The interface for the execution process is as follows:
3) initialize the database (under windows, go to the Python installation directory (or the virtual directory of virtualEnv), lib\ site-packages\ superset\ bin)
Execute the command:
Python superset db upgrade
4) load examples (all subsequent operations need to be done under lib\ site-packages\ superset\ bin)
Python superset load_examples
5) initialize roles and permissions
Python superset init
6) start the service, port 8088, and use-p to change the port number.
Python superset runserver-d4. Configure the data source
Superset uses sqllite by default. The following databases are supported:
MySQL
Pip install mysqlclient
Mysql://
Postgres
Pip install psycopg2
Postgresql+psycopg2://
Presto
Pip install pyhive
Presto://
Oracle
Pip install cx_Oracle
Oracle://
Sqlite
By default, there is.
Sqlite://
Redshift
Pip install sqlalchemy-redshift
Postgresql+psycopg2://
MSSQL
Pip install pymssql
Mssql://
Impala
Pip install impyla
Impala://
SparkSQL
Pip install pyhive
Jdbc+hive://
Greenplum
Pip install psycopg2
Postgresql+psycopg2://
Athena
Pip install "PyAthenaJDBC > 1.0.9"
Awsathena+jdbc://
Vertica
Pip install sqlalchemy-vertica-python
Vertica+vertica_python://
ClickHouse
Pip install sqlalchemy-clickhouse
Clickhouse://
After installing the database using pip, you can configure the relevant data sources in the Web interface.
For the connection string format of the database, see:
Http://docs.sqlalchemy.org/en/rel_1_0/core/engines.html#database-urls
5. Log in for trial
After logging in to superset, we can configure our own local data source, query and display the data.
6. Embed background application 6.1 modify configuration file
Modify the config.py configuration file in superset to change PUBLIC_ROLE_LIKE_GAMMA to True.
The meaning of the note:
Grant the public role the same set of permissions as the GAMMA role.
If you want anonymous users to view it, you can set it here, and the authorization display for a specific dataset on the dashboard can also be set here.
6.2 remove the X-Frame-Options restriction
Avoid iframe cross-site access problems.
6.3 add database permissions all database permissions are added here
Where:
Z can explore on Superset to export the chart
^ can explore json on Superset is the export chart json
0 all database access on all_database_access access all database permissions, or you can set a single
6.4 iframe embedding
The effect is as follows:
7. Redirect Superset Chart URL
Why do you need to redirect? The main purpose here is to hide the superset chart link for the background application to prevent malicious use after being scanned. As long as the background application rewrites a request link with permission control and redirects to the superset chart link, it can prevent data from leaking out.
Background code:
Then, for the link address: / chart/getDemoDashboardUrl, permissions can be managed in the background.
8. Interactive implementation of dynamic parameter transfer
The above can embed the chart in superset into the background application system, but how can you pass the parameters? Now, I'll sort out the implementation process here and follow the experimental example to see how it works.
If you take a look at the link address provided by the superset chart, you can see that json has been passed as a parameter. As follows:
Form_data= {"datasource": "3__table", "viz_type": "line", "slice_id": 63, "granularity_sqla": "ds", "time_grain_sqla": null, "since": "100 years ago", "until": "now", "metrics": [{"aggregate": "SUM", "column": {"column_name": "num_california", "expression": "CASE WHEN state = 'CA' THEN num ELSE 0 END"}, "expressionType": "SIMPLE" "label": "SUM (num_california)"}], "adhoc_filters": [{"expressionType": "SIMPLE", "subject": "gender", "operator": "=", "comparator": "boy", "clause": "WHERE", "sqlExpression": null, "fromFormData": true, "filterOptionName": "filter_gtzm93u9ocq_9sy5vd5ocfg"}, {"expressionType": "SIMPLE", "subject": "name", "operator": "LIKE", "comparator": "Aaron", "clause": "WHERE" "sqlExpression": null, "fromFormData": true, "filterOptionName": "filter_6cgdixdoh4_5wrgyuorwoa"}], "groupby": ["name"], "limit": "10", "timeseries_limit_metric": {"aggregate": "SUM", "column": {"column_name": "num_california", "expression": "CASE WHEN state = 'CA' THEN num ELSE 0 END"}, "expressionType": "SIMPLE", "label": "SUM (num_california)"}, "order_desc": true "contribution": false, "row_limit": 50000, "color_scheme": "bnbColors", "show_brush": "auto", "show_legend": true, "rich_tooltip": true, "show_markers": false, "line_interpolation": "linear", "x_axis_label": "auto", "x_ticks_layout": "auto", "x_axis_format": "smart_date", "x_axis_showminmax": false "y_axis_label": "," left_margin ":" auto "," y_axis_showminmax ": false," y_log_scale ": false," y_axis_format ":" .3s "," y_axis_bounds ": [null,null]," rolling_type ":" None "," time_compare ": []," num_period_compare ":"," period_ratio_type ":" growth "," resample_how ": null," resample_rule ": null "resample_fillmethod": null, "annotation_layers": [], "compare_lag": "10", "compare_suffix": "o10Y", "markup_type": "markdown", "metric": "sum__num", "where": "," url_params ": {}}
Among them, the parameter configuration marked × × is the parameter configuration of the filter condition, so it is extracted and modified accordingly in the code:
The modified interface is as follows:
Enter the criteria, name: Amy, gender selection: girl, click to query as follows:
9. Concluding remarks
The above practice is the process of pre-research superset visualization tools, the preparation of samples are very simple. If it is actually applied to the project, redesign a set of expandable and easy-to-use architecture according to the principle of appeal, and polish it into a configurable product tool. Leave a foreshadowing here, do not elaborate for the time being, if you have good ideas, welcome to leave a message to exchange.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.