diff --git a/notebooks/cloud-functions-template/notebook.ipynb b/notebooks/cloud-functions-template/notebook.ipynb index 4cbc7123..0da65c01 100644 --- a/notebooks/cloud-functions-template/notebook.ipynb +++ b/notebooks/cloud-functions-template/notebook.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "markdown", - "id": "e0f88a6f-2658-40b4-9356-935a09f5053e", + "id": "cd7deb95-c7bb-48eb-9cab-ed508b3be5ff", "metadata": {}, "source": [ "
\n", @@ -34,7 +34,6 @@ "attachments": {}, "cell_type": "markdown", "id": "a5564913-7ff8-41bf-b64b-b67971c63fae", - "metadata": {}, "source": [ "This Jupyter notebook will help you build your first Cloud Function, showcasing how to leverage the ultra-fast queries of SingleStore to build a responsive API server using FastAPI" ] @@ -43,7 +42,6 @@ "attachments": {}, "cell_type": "markdown", "id": "1e394195-29b4-403c-9abf-5d7731349eb6", - "metadata": {}, "source": [ "## Create some simple tables\n", "\n", @@ -54,7 +52,6 @@ "cell_type": "code", "execution_count": 1, "id": "a17bdd3a-16b3-4e19-8a56-6566a169eccb", - "metadata": {}, "outputs": [], "source": [ "%%sql\n", @@ -72,7 +69,6 @@ "attachments": {}, "cell_type": "markdown", "id": "af6e2618-de97-4397-b0d2-23e4a4df1d83", - "metadata": {}, "source": [ "## Create a Connection Pool\n", "\n", @@ -83,7 +79,6 @@ "cell_type": "code", "execution_count": 2, "id": "f485e71b-2b05-4696-b22a-cf046fd83090", - "metadata": {}, "outputs": [], "source": [ "from sqlalchemy import create_engine, text\n", @@ -96,9 +91,8 @@ "with open(ca_cert_path, \"wb\") as f:\n", " f.write(response.content)\n", "\n", - "sql_connection_string = connection_url.replace(\"singlestoredb\", \"mysql+pymysql\")\n", "engine = create_engine(\n", - " f\"{sql_connection_string}?ssl_ca={ca_cert_path}\",\n", + " f\"{connection_url}?ssl_ca={ca_cert_path}\",\n", " pool_size=10, # Maximum number of connections in the pool is 10\n", " max_overflow=5, # Allow up to 5 additional connections (temporary overflow)\n", " pool_timeout=30 # Wait up to 30 seconds for a connection from the pool\n", @@ -124,7 +118,6 @@ "attachments": {}, "cell_type": "markdown", "id": "ee9058a9-34a5-46fc-8b12-d30cbb8c3340", - "metadata": {}, "source": [ "## Setup Environment\n", "\n", @@ -135,7 +128,6 @@ "cell_type": "code", "execution_count": 3, "id": "66df8f0c-70c6-4f06-9e64-ef06961cca3a", - "metadata": {}, "outputs": [], "source": [ "from fastapi import FastAPI, HTTPException\n", @@ -161,7 +153,6 @@ "attachments": {}, "cell_type": "markdown", "id": "96760949-5ab2-474d-80ca-d23b5dcc52f7", - "metadata": {}, "source": [ "## Define FastAPI App\n", "\n", @@ -172,7 +163,6 @@ "cell_type": "code", "execution_count": 4, "id": "3087dbe6-57ce-4410-a42f-5b0fe90add90", - "metadata": {}, "outputs": [], "source": [ "app = FastAPI()\n", @@ -188,6 +178,7 @@ " try:\n", " return await run_in_thread(get_items_query)\n", " except Exception as e:\n", + "\n", " raise HTTPException(status_code=500, detail=f\"Error fetching all items: {str(e)}\")\n", "\n", "# Insert an item\n", @@ -236,7 +227,6 @@ "attachments": {}, "cell_type": "markdown", "id": "c3d9ed07-4b55-4d17-aabb-e11b399109d1", - "metadata": {}, "source": [ "## Start the FastAPI server\n", "\n", @@ -247,7 +237,6 @@ "cell_type": "code", "execution_count": 5, "id": "ff002c7d-9f1c-40e5-b82a-c9176251dc99", - "metadata": {}, "outputs": [], "source": [ "import singlestoredb.apps as apps\n", @@ -258,7 +247,6 @@ "attachments": {}, "cell_type": "markdown", "id": "fabe76b7-e6a0-43a0-8d9e-aa79bd7d3021", - "metadata": {}, "source": [ "## Publish Cloud Function\n", "\n", @@ -267,7 +255,7 @@ }, { "cell_type": "markdown", - "id": "55513fb9-f288-4cf1-b371-a71439bb1a31", + "id": "386f804b-f3a9-4452-9575-b87c917bbbf8", "metadata": {}, "source": [ "
\n", @@ -275,31 +263,6 @@ ] } ], - "metadata": { - "jupyterlab": { - "notebooks": { - "version_major": 6, - "version_minor": 4 - } - }, - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.6" - } - }, "nbformat": 4, "nbformat_minor": 5 } diff --git a/notebooks/create-dash-app/notebook.ipynb b/notebooks/create-dash-app/notebook.ipynb index 8aed0b8a..b3c5ccfb 100644 --- a/notebooks/create-dash-app/notebook.ipynb +++ b/notebooks/create-dash-app/notebook.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "markdown", - "id": "c5893325-17c9-495f-862f-049072c30806", + "id": "1d98a67c-972c-43fd-8947-e251dc1b5b96", "metadata": {}, "source": [ "
\n", @@ -34,7 +34,6 @@ "attachments": {}, "cell_type": "markdown", "id": "df860ca4-6db8-4ded-a061-30be438c4add", - "metadata": {}, "source": [ "This Jupyter notebook will help you build your first real time Dashboard, showcasing how to leverage the ultra-fast queries of SingleStore to build a great visual experience using Plotly's DashApps." ] @@ -54,7 +53,6 @@ "cell_type": "code", "execution_count": 1, "id": "d218d020-b9dc-4419-961d-2232ca0893f8", - "metadata": {}, "outputs": [], "source": [ "%%sql\n", @@ -72,7 +70,6 @@ "attachments": {}, "cell_type": "markdown", "id": "c6e492c6-74c8-488f-a456-fae59af0c69d", - "metadata": {}, "source": [ "## Insert some data\n", "\n", @@ -83,7 +80,6 @@ "cell_type": "code", "execution_count": 2, "id": "98e60d97-42ce-4600-8e35-556c70f9d4c2", - "metadata": {}, "outputs": [], "source": [ "%%sql\n", @@ -115,7 +111,6 @@ "attachments": {}, "cell_type": "markdown", "id": "beb57814-ad38-4065-a730-59576f6a72e3", - "metadata": {}, "source": [ "## Create a Connection Pool\n", "\n", @@ -126,7 +121,6 @@ "cell_type": "code", "execution_count": 3, "id": "f030ce86-4940-4014-8227-6b8c9cb56246", - "metadata": {}, "outputs": [], "source": [ "from sqlalchemy import create_engine, text\n", @@ -139,9 +133,8 @@ "with open(ca_cert_path, \"wb\") as f:\n", " f.write(response.content)\n", "\n", - "sql_connection_string = connection_url.replace(\"singlestoredb\", \"mysql+pymysql\")\n", "engine = create_engine(\n", - " f\"{sql_connection_string}?ssl_ca={ca_cert_path}\",\n", + " f\"{connection_url}?ssl_ca={ca_cert_path}\",\n", " pool_size=10, # Maximum number of connections in the pool is 10\n", " max_overflow=5, # Allow up to 5 additional connections (temporary overflow)\n", " pool_timeout=30 # Wait up to 30 seconds for a connection from the pool\n", @@ -156,7 +149,6 @@ "attachments": {}, "cell_type": "markdown", "id": "dd87d196-3d52-4f3a-8dd4-d5f3540b051f", - "metadata": {}, "source": [ "## Create a line chart\n", "\n", @@ -169,7 +161,6 @@ "cell_type": "code", "execution_count": 4, "id": "712cd20d-6f2d-4c5a-9094-11b611ce622d", - "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", @@ -201,7 +192,6 @@ "attachments": {}, "cell_type": "markdown", "id": "cc363aa0-a8d5-4f7e-bdae-5a22d56e0bcf", - "metadata": {}, "source": [ "## Create a pie chart\n", "\n", @@ -212,7 +202,6 @@ "cell_type": "code", "execution_count": 5, "id": "79aa80ef-4a49-4238-87fb-f90a16ba4e42", - "metadata": {}, "outputs": [], "source": [ "def generate_pie_chart(date):\n", @@ -233,7 +222,6 @@ "attachments": {}, "cell_type": "markdown", "id": "94586a2e-76b2-48f8-8dbd-ff7038443ae1", - "metadata": {}, "source": [ "## Define the Dash App Layout and Callbacks\n", "\n", @@ -245,7 +233,6 @@ "cell_type": "code", "execution_count": 6, "id": "de733262-834b-48b6-b885-78dfc5ebb452", - "metadata": {}, "outputs": [], "source": [ "from singlestoredb import apps\n", @@ -321,7 +308,6 @@ "attachments": {}, "cell_type": "markdown", "id": "f287e202-704b-4eb5-8290-fb08ba9a493c", - "metadata": {}, "source": [ "## Start the Dash App server\n", "\n", @@ -332,7 +318,6 @@ "cell_type": "code", "execution_count": 7, "id": "69632c1b-f981-4338-9f91-ca8ae746cd73", - "metadata": {}, "outputs": [], "source": [ "connectionInfo = await apps.run_dashboard_app(app)" @@ -342,7 +327,6 @@ "attachments": {}, "cell_type": "markdown", "id": "4fe4abd0-d52f-475a-89a4-d518f2b37d0d", - "metadata": {}, "source": [ "## Publish Dashboard\n", "\n", @@ -351,7 +335,7 @@ }, { "cell_type": "markdown", - "id": "8eb7fab3-c714-4b3b-93a7-ce8a9836ded2", + "id": "5da7ba27-6006-48c2-92a5-ea2bd2e609a3", "metadata": {}, "source": [ "
\n", @@ -359,31 +343,6 @@ ] } ], - "metadata": { - "jupyterlab": { - "notebooks": { - "version_major": 6, - "version_minor": 4 - } - }, - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.6" - } - }, "nbformat": 4, "nbformat_minor": 5 }