Skip to content

Commit

Permalink
getting-started-with-notebooks db syntax updated
Browse files Browse the repository at this point in the history
  • Loading branch information
demenskyi committed Jan 26, 2024
1 parent b1b90e1 commit 3418afa
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 8 deletions.
2 changes: 1 addition & 1 deletion notebooks/getting-started-with-notebooks/meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ description="""\
visualization and analysis. \
"""
icon="notes"
tags=["beginner", "sqrl"]
tags=["starter", "python", "sqrl"]
destinations=["spaces"]
64 changes: 57 additions & 7 deletions notebooks/getting-started-with-notebooks/notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
"</div>"
]
},
{
"cell_type": "markdown",
"id": "4e83c63b",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-warning\">\n",
" <b class=\"fa fa-solid fa-exclamation-circle\"></b>\n",
" <div>\n",
" <p><b>Note</b></p>\n",
" <p> This notebook can be run on a Free Starter Workspace. To create a Free Starter Workspace navigate to <tt>Start</tt> using the left nav. You can also use your existing Standard or Premium workspace with this Notebook. </p>\n",
" </div>\n",
"</div>"
]
},
{
"cell_type": "markdown",
"id": "6d2bb122-3ae2-4eab-bbbd-3e3ba6907c4b",
Expand Down Expand Up @@ -140,6 +154,20 @@
"df.dtypes"
]
},
{
"cell_type": "markdown",
"id": "3a9c4139",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-warning\">\n",
" <b class=\"fa fa-solid fa-exclamation-circle\"></b>\n",
" <div>\n",
" <p><b>Action Required</b></p>\n",
" <p> If you have a Free Starter Workspace deployed already, select the database from drop-down menu at the top of this notebook. It updates the <tt>connection_url</tt> to connect to that database.</p>\n",
" </div>\n",
"</div>"
]
},
{
"cell_type": "markdown",
"id": "4ceef3c0-c804-48c3-9ca0-dcb7f5abfe27",
Expand Down Expand Up @@ -193,17 +221,24 @@
"metadata": {},
"outputs": [],
"source": [
"%%sql\n",
"DROP DATABASE IF EXISTS {{database_name}};\n",
"CREATE DATABASE {{database_name}};"
"shared_tier_check = %sql show variables like 'is_shared_tier'\n",
"if not shared_tier_check or shared_tier_check[0][1] == 'OFF':\n",
" %sql DROP DATABASE IF EXISTS {{database_name}};\n",
" %sql CREATE DATABASE {{database_name}};"
]
},
{
"cell_type": "markdown",
"id": "b8f95d65-b3ca-4306-b22c-11f8eadcce13",
"id": "7defddbb",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-warning\"> <b class=\"fa fa-solid fa-exclamation-circle\"></b> <div> <p><b>Action Required</b></p> <p>Make sure to select the <tt>getting_started_notebook</tt> database from the drop-down menu at the top of this notebook. It updates the <tt>connection_url</tt> which is used by the <tt>%%sql</tt> magic command and SQLAlchemy to make connections to the selected database.</p> </div></div>"
"<div class=\"alert alert-block alert-warning\">\n",
" <b class=\"fa fa-solid fa-exclamation-circle\"></b>\n",
" <div>\n",
" <p><b>Action Required</b></p>\n",
" <p> Make sure to select a database from the drop-down menu at the top of this notebook. It updates the <tt>connection_url</tt> to connect to that database.</p>\n",
" </div>\n",
"</div>"
]
},
{
Expand Down Expand Up @@ -386,15 +421,30 @@
"## 6. Cleanup database"
]
},
{
"cell_type": "markdown",
"id": "fb94bc57",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-warning\">\n",
" <b class=\"fa fa-solid fa-exclamation-circle\"></b>\n",
" <div>\n",
" <p><b>Action Required</b></p>\n",
" <p> If you created a new database in your Standard or Premium Workspace, you can drop the database by running the cell below. Note: this will not drop your database for Free Starter Workspaces. To drop a Free Starter Workspace, terminate the Workspace using the UI. </p>\n",
" </div>\n",
"</div>"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "0792f4a6-82f4-413b-9895-cd4764f7a118",
"metadata": {},
"outputs": [],
"source": [
"%%sql\n",
"DROP DATABASE {{database_name}};"
"shared_tier_check = %sql show variables like 'is_shared_tier'\n",
"if not shared_tier_check or shared_tier_check[0][1] == 'OFF':\n",
" %sql DROP DATABASE IF EXISTS {{database_name}};"
]
},
{
Expand Down

0 comments on commit 3418afa

Please sign in to comment.