Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for CockroachDB Integration with Superset
sue enuga
sue enuga

Posted on

     

CockroachDB Integration with Superset

What is Superset ??

Superset is a fast, lightweight modern web application that is loaded with options that make it easy for users of all skill sets to explore and visualize their data, from simple pie charts to highly detailed deck.gl geospatial charts. so, in simple words its used for analyzing your data.

Why Integrate it with CockroachDB ??

CockraochDB is a highly available & reliable database which makes consistency as a priority and is best suited for all your OLTP needs.However, to analyze this data you can use any intelligent visualization tools. One of such easy lightweight tool is Apache Superset. Together with Superset & CockroachDB now you have a Datastore with analytical capabilities.

Installing Superset with docker

Pre-requisite:Docker
There seems to be multiple ways to install superset. I wanted to try out the installation using Docker as its the most recommended approach. You can follow the Installation instructions from theirdocs.
See below images for reference.

docker-terminal

docker-container

superset-intro

Note: superset is not officially supported in Windows as of 04/23, So, if you need to test this out, quickly spin up a linux/mac instance on hyperV or something similar.

Integrating Superset with cockroachDB

Pre-requisite: Working instance of CockroachDB and its connection parameters.
CockroachDB has multiple offerings & you can use any of these to integrate with superset. I used the serverless instance of CRDB here for the exercise.
For folks who are familiar withCockroach workload, I loaded my serverless instance withMOVR workload
According to Supersetdocumentation to integrate Superset with cockroachDB, Superset requires a python DB-API database driver and a SQL Alchemy dialect to be installed for cockroachDB. Now, lets see how to install the driver.

Installing the database driver to support cockroachDB

1.Create requirements-local.txt

# From the repo root...touch ./docker/requirements-local.txt
Enter fullscreen modeExit fullscreen mode

2.Add thecockroachdb driver

echo "cockroachdb" >> ./docker/requirements-local.txt
Enter fullscreen modeExit fullscreen mode

3.Rebuild your local docker image with new driver

docker-compose build --force-rm
Enter fullscreen modeExit fullscreen mode

4.Start Superset via Docker Compose

docker-compose -f docker-compose-non-dev.yml pulldocker-compose -f docker-compose-non-dev.yml up
Enter fullscreen modeExit fullscreen mode

Now, superset should have all the necessary packages installed for connecting with CockroachDB.

Adding Cockroach DB as a data store in Superset

1.Go to Superset UI atlocalhost:8088 and login.
2.On the right top corner, next tosettings you'll see a+ icon. click on it & selectData and navigate toconnect database. See below image for reference.

susperset-UI

  1. In the window you'll be prompted toSelect a database to connect and here you'll need to go to theSupported Databases and choosecockroachDB. See below image

select-db

In second screen after selecting cockroachDB, you need to provide the connection details. Enter the primary Credentials, selectBasic and enter theSQLAlCHEMY URI which should be formatted specifically for cockroach DB. See below on how to format it.

cockroachdb://root:pass@{hostname}:{port}/{database}?sslmode=verify-fullexample: cockroachdb://sue:samplepassword@sue-sampletest-host:26257/movr?sslmode=verify-full
Enter fullscreen modeExit fullscreen mode

Connect-db

As I'm using a secure serverless cluster,I'm required to provide myroot.crt in theSecurity section, underRoot Certificate. So, I copied the root cert which is by default located in the$HOME/.postgresql/root.crt.

adv-sec

4.Once the connection is successful, you'll seeCockroachDB in the SupersetDatabases

integration-db

Creating Dashboards in Superset

Creating Dashboards in Superset is super simple, you can follow theirdocs for creating your first dashboard.

I created a bunch of dashboards for my dataset, see below image for reference.

dashboard-sue

Yay !! There you go, you have now successfully integrated cockroachDB with Superset and created some dashboards as well.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Always on a mission to break and make applications.
  • Location
    Austin, Texas
  • Joined

More fromsue enuga

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp