Download and Install the Plotly Database Connector App
Launch and Connect
Having launched the app, select MariaDB by clicking on its icon.
Enter your username, password, database server name (host) and its port number.
Have no database? Try it out with our read-only MariaDB database:
You can leave the port empty, it will default to 3306
NOTE: If you are running your database locally, the host input field can stay empty since its default value is 'localhost'. Similarly, if your database is setup on port number 3306, you may leave the port input field empty as well. If your database is setup on a remote server, simply copy the endpoint name into the host input field and enter the remote server's port number on which your database is located.
Finally, click on the connect button!
Once connection is established, your connection credentials will be saved and greyed out to avoid unintentional changes. If you wish to modify your connection, click on edit credentials.
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). For this example, let's select the 2011 data for USA agricultural exports which is the table named us_ag_exports_2011
Scroll down to to see the full table if it does not fit in the preview window. In this example we will look into beef exports, and by looking at the column names (we have code and beef) and the data formatting (state codes and integers respectively), we should be confident that we can accomplish a visualisation that can compare the states based on their beef export in Plotly.
Send a Query to Your Database
Once you have successfully certified your database credentials and you have an automatically generated an SSL, you are setup to begin querying data in Plotly. It is important to note that the automatically generated SSL can sometimes take up to several minutes, but don't worry, this authorization only needs to be completed once. Once you can see that is has been generated, click the 'Click to Open Query Editor' link under the 'Final Step. Query Data on Plotly' section. This will open the Plotly workspace in your default browser.
Now, the SQL import modal will appear. Simply, clik 'Next'
Verify that both 'https' is selected and your unique address is in the text box. Then click Connect
The modal will close and a new panel will be added to your Plotly Chart Creator.
On the right, your available connections from the Plotly Database Connector will be displayed. If you have more than one, make sure you select the database connection that you want to use when writing the query.
Once your query is finalized, click Run Query. If you wish to set your query on a schedule to keep your grid's data updated to the latest entries of your database, visit our schedule a query tutorial.
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 graph 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.