Show Sidebar Hide Sidebar

Connect Your Charts and Dashboards to a SQLite Database

Graph data from your SQLite database with Plotly 2.0 and the Plotly Database Connector.

Step 1

Download and Install the Plotly Database Connector App

Please note that SQLite currently is supported on Mac OS only. Linux and Windows support will come shortly. Thank you for your patience.

Simply Download the app to get started!

Step 2

Launch and Connect

Having launched the app, select SQlite by clicking on its icon.

Click on the path to database input field and a dialog window will open. Navigate to your local database file (having a .db extension). If your data is in csv format, convert it first to a database .db file.

The dialog menu will only allow you to select a database .db file.

Finally, click on the connect button!

Step 3

Choose A Database

Once connected, a dropdown menu will appear. When using sqlite, the .db file itself is the one and only database which will contain one or many tables. Thus the database dropdown menu will be greyed out since there are no choices of databases. Your connection to it is established and the preview of each table are displayed.

Step 4

Preview Your Tables

A dropdown menu will appear. The options are the tables of the database previously selected. Select the table you wish to preview (see the top 5 rows of the table).

Scroll down to to see the full table if it does not fit in the preview window.

Step 5

Send a Query to Your Database

Having connected your app, visit plot.ly workspace and click on import data in the top right corner.

Choose SQL from the options on the left.

A connection endpoint will be suggested. By default, the connector runs on http://localhost:5000. To use that default endpoint you will have to let your browser use unsafe scripts (the above endpoint uses http protocal instead of https). To do so simply keep reading the following steps. If your data is highly sensitive, you can setup your Plotly Database Connector to use the more secure https protocol to transfer data. If you are on Mac or Linux, follow instructions on Step 3 of your Plotly Database Connector. Https support for Windows is shortcoming, thank you for your patience.

If you chose to pursue using the http protocol, simply keep the endpoint as default http://localhost:5000 and click on connect.

You should receive an error. Make sure your browser's safe scripting setting is turned off. Click on the icon inside your search bar to disable it (a shield icon if you are using the Chrome browser (recommended)).

Once connected, you will see an SQL editor along with a database dropdown menu. Select the database from the dropdown menu to connect to that database. In this example, let's use plotly_datasets.

Having selected a database from the dropdown menu, a query will appear on the first line of the editor. Modify it until you are satisfied with the data that you are querrying from your database. For this example, let's quickly import all of the data from the agricultural imports table us_ag_exports_2011. Enter the query SELECT * FROM us_ag_exports_2011. Where * is a SQL keyword for 'all'.

To execute the query, click on RUN QUERY button.

Your data will be imported into the grid below. You can now create a plot using the imported data from your SQL database.

Step 6

Making a plot!

Let's visualize the beef exports by state on a map. On the left side, the GRAPH tab should be selected. Here you can choose the Chart Type drop down menu. Choose Choropleth. As for Locations, choose the state column. Finally, set the Values to be the beef column.

Since our code column data is in three letter state codes, select the Location Format to be USA State Abbreviations. We are only looking at USA data here, so for the Map Region option select USA. Finally, let's keep it simple and keep the Projection option as the default Albers USA. Come back later to explore more options.

Look to the right! You graph should be already updated. Why not add a title? Click into the empty field above the garph and enter a description.

Let's not lose all this work! Let's save the graph. Click on the SAVE tab on the left.

You will be prompted to choose your privacy settings for this graph and data. There is nothing here to classify, let's simply set both plot and data to public. Click SAVE.

Let's share this interactive plot with a friend or a coworker (or both)! Click on the SHARE tab on the left.

The fastest way is to send the Shareable Link, copy and paste it into your favorite e-mail or other communication service. Try out our Twitter, Facebook and Google+ links as well or embed it into your website by obtaining the iframe link in the Embed tab. If you set the settings to public previously, your friend or coworker will be able to view it even without an account and give you feedback.

Step 7

Disconnect

When your are finished creating graphs using the data from your database, disconnect by moving your mouse onto the Connected button in the Plotly Database Connector and click when it says Disconnect.

Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to our Premium or Enterprise plans.