{"id":255,"date":"2020-06-30T00:03:50","date_gmt":"2020-06-30T07:03:50","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sql\/?p=255"},"modified":"2020-07-01T06:05:34","modified_gmt":"2020-07-01T13:05:34","slug":"querying-and-visualizing-data-using-sqlpad","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sql\/querying-and-visualizing-data-using-sqlpad\/","title":{"rendered":"Querying and visualizing data using SQLPad"},"content":{"rendered":"<p><a href=\"https:\/\/rickbergfalk.github.io\/sqlpad\/#\/\">SQLPad<\/a> is an amazing free, open source, tool to run SQL Queries against a broad spectrum of popular databases, without the need to install and run something on-premises. It&#8217;s lightweight, simple and just perfect if you need a no-frills tool to query and visualize data, to do some data exploration.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-260 size-large\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/06\/sqlpad-2-1024x500.png\" alt=\"Image sqlpad 2\" width=\"640\" height=\"313\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/06\/sqlpad-2-1024x500.png 1024w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/06\/sqlpad-2-300x147.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/06\/sqlpad-2-768x375.png 768w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/06\/sqlpad-2-1536x750.png 1536w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/06\/sqlpad-2.png 1916w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>As a developer, especially if you are not that much into data, you probably don\u2019t always need all the features that full-fledged product like SQL Server Management Studio or other on-premises tool provides. You need something lean and simple. But not too simple. And in addition to that, you may want to use a cloud tool to query data that lives in the cloud. I&#8217;ve found a very nice community driven and open source tool that hits this sweet spot, at this tool is SQLPad.<\/p>\n<p>This is of course not a substitute for SQL Server Management Studio or Azure Data Studio, but I find it very handy when I don&#8217;t need all the complexity of those tools. Also, when I&#8217;m on low-bandwidth connections (yeah, not everywhere you have the luxury to have a broadband) this is really a super useful tool.<\/p>\n<p>Completely written in Node, it uses Sequelize to abstract from any vendor-specific requirements so that you can query anything from Azure SQL to Vertica, going through Postgres, MySQL, MariaDB and so on. Just perfect if you are working on a modern solution where different services may use different database and you need one place to run your queries.<\/p>\n<p>Up until today, SQLPad couldn&#8217;t easily run on Azure, as it was using SQLite to store all its metadata, and SQLite doesn&#8217;t really work well, <a href=\"https:\/\/github.com\/MicrosoftDocs\/azure-docs\/issues\/47130\">yet<\/a>, with Azure Storage File Share. Since I didn&#8217;t see the point of use SQLite when Azure SQL could be used, since probably you are already using it for some project, I helped the maintainer of the project and added support to Azure SQL (and, more in general, to other databases).<\/p>\n<p>I&#8217;m pretty happy, as I helped both the <a href=\"https:\/\/github.com\/sequelize\/sequelize\/pull\/12404\">Sequelize project<\/a> and the <a href=\"https:\/\/github.com\/rickbergfalk\/sqlpad\">SQLPad<\/a> project&#8230;and give than when I started I really had almost zero knowledge of Node&#8230;well I&#8217;m pretty happy about myself \ud83d\ude42 I have learned something, and at the same time I helped a community project. That&#8217;s a win-win! But enough with self-gratification now, the most important result is that now you can run SQLPad using Azure Container Instances.<\/p>\n<h2>Spinning Up SQLPad<\/h2>\n<p>All you need to do to run SQLPad is making sure you have an Azure SQL database ready to be used to store metadata, and then you just need to create a new Azure Container:<\/p>\n<pre class=\"prettyprint\">az container create -g &lt;resource-group&gt; -n &lt;container-name&gt; \\\r\n\t--image sqlpad\/sqlpad \\\r\n\t--ports 3000 \\\r\n\t--ip-address \"Public\" \\\r\n\t--secure-environment-variables SQLPAD_BACKEND_DB_URI='mssql:\/\/&lt;user&gt;:&lt;password&gt;@&lt;server&gt;.database.windows.net\/&lt;database&gt;?options={\"encrypt\":true}' \\\r\n\t--cpu 2 \\\r\n\t--memory 4<\/pre>\n<p>and in just a minute or less, thanks to the SQLPAD_BACKEND_DB_URI environment variable and the Sequelize support to URI connection string, you&#8217;ll have SQLPad up and running.<\/p>\n<p>You can get the IP Address of the running container via the Azure Portal or using the following command:<\/p>\n<pre class=\"prettyprint\"> az container show -g &lt;resource-group&gt; -n &lt;container-name&gt; --query \"ipAddress.ip\" -o tsv<\/pre>\n<p>Then you can connect to SQLPad at http:\/\/&lt;ip-address&gt;:3000<\/p>\n<h2>Accessing SQLPad the first time<\/h2>\n<p>The first time you&#8217;ll try to access SQL you need to\u00a0<em>sign-up<\/em>, and this first account will also be set as the administrative account.<\/p>\n<p><img decoding=\"async\" class=\"size-medium wp-image-261 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/06\/sqlpad-1-300x208.png\" alt=\"Image sqlpad 1\" width=\"300\" height=\"208\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/06\/sqlpad-1-300x208.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/06\/sqlpad-1.png 522w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>There are several options for authenticating users, all described in the <a href=\"https:\/\/rickbergfalk.github.io\/sqlpad\/#\/authentication\">guide<\/a>. After you have defined the administrative account, you can login with the newly created account and then start to create a <em>connection<\/em>.<\/p>\n<h2>Querying data using SQLPad<\/h2>\n<p>After you logged you, you need to create a\u00a0<em>connection<\/em> or use an existing one.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-262 size-medium\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/06\/sqlpad-3-300x98.png\" alt=\"Image sqlpad 3\" width=\"300\" height=\"98\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/06\/sqlpad-3-300x98.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/06\/sqlpad-3-768x250.png 768w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/06\/sqlpad-3.png 802w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>Once the connection is selected you can start querying. Once you are done, if you don&#8217;t want to spend money while you are not using SQLPad, you can destroy the container using the following command:<\/p>\n<pre class=\"prettyprint\"> az container delete -g &lt;resource-group&gt; -n &lt;container-name&gt; -y<\/pre>\n<p>We you&#8217;ll need to use SQLPad again, you can run the command you used to deploy SQLPad the first time. Thanks to Sequelize and the defined migrations, database metadata will not be created, so you will find all the defined connections, users and query ready for you to be operative in no time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQLPad is an amazing free, open source, tool to run SQL Queries against a broad spectrum of popular databases, without the need to install and run something on-premises. It&#8217;s lightweight, simple and just perfect if you need a no-frills tool to query and visualize data, to do some data exploration.<\/p>\n","protected":false},"author":24720,"featured_media":260,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[30,355],"class_list":["post-255","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-sql","tag-developers","tag-tools"],"acf":[],"blog_post_summary":"<p>SQLPad is an amazing free, open source, tool to run SQL Queries against a broad spectrum of popular databases, without the need to install and run something on-premises. It&#8217;s lightweight, simple and just perfect if you need a no-frills tool to query and visualize data, to do some data exploration.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/users\/24720"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/comments?post=255"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/255\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media\/260"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media?parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/categories?post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/tags?post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}