Skip to content

Commit

Permalink
Change sqlalchemy.create_engine to singlestoredb.create_engine
Browse files Browse the repository at this point in the history
  • Loading branch information
kesmit13 committed Jul 24, 2023
1 parent 8e4faf0 commit 5be2a78
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 11 deletions.
25 changes: 24 additions & 1 deletion notebooks/getting-started-with-notebooks/notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,30 @@
"import sqlalchemy as sa\n",
"\n",
"# Create a SQLAlchemy engine and connect\n",
"db_connection = sa.create_engine(connection_url).connect()\n",
"db_connection = sa.create_engine(connection_url).connect()"
]
},
{
"cell_type": "markdown",
"id": "515fb529-745f-4005-a704-241dfe65e985",
"metadata": {},
"source": [
"The SingleStoreDB Python package also adds a convenience function for SQLAlchemy connections\n",
"without using the `connection_url`. It automatically gets the connection information from \n",
"the `SINGLESTOREDB_URL` environment variable."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "16f8f5df-6019-4fbb-9d4e-e1dd389ea7af",
"metadata": {},
"outputs": [],
"source": [
"import singlestoredb as s2\n",
"\n",
"# Create a SQLAlchemy engine and connect, without having to specify the connection URL\n",
"db_connection = s2.create_engine().connect()\n",
"\n",
"# Upload the DataFrame\n",
"df.to_sql('sf_restaurant_scores', con=db_connection, if_exists='append', chunksize=1000)"
Expand Down
4 changes: 2 additions & 2 deletions notebooks/image-matching-with-sql/notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"import numpy as np\n",
"import pandas as pd\n",
"import requests\n",
"import sqlalchemy as sa\n",
"import singlestoredb as s2\n",
"import tensorflow.compat.v1 as tf\n",
"from botocore import UNSIGNED\n",
"from botocore.client import Config\n",
Expand Down Expand Up @@ -194,7 +194,7 @@
" converters=dict(vector=json_to_numpy_array))\n",
"\n",
"# Create database connection\n",
"db_connection = sa.create_engine(connection_url).connect()\n",
"db_connection = s2.create_engine().connect()\n",
"\n",
"# Upload DataFrame\n",
"df.to_sql('people', con=db_connection, index=False, if_exists='append')"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "e4bb409e",
"metadata": {},
Expand Down Expand Up @@ -105,9 +104,9 @@
"metadata": {},
"outputs": [],
"source": [
"from sqlalchemy import *\n",
"from singlestoredb import create_engine\n",
"\n",
"db_connection = create_engine(connection_url)"
"db_connection = create_engine().connect()"
]
},
{
Expand Down Expand Up @@ -249,7 +248,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions notebooks/movie-recommendation/notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@
"metadata": {},
"outputs": [],
"source": [
"from sqlalchemy import create_engine\n",
"from singlestoredb import create_engine\n",
"\n",
"db_connection = create_engine(connection_url).connect()"
"db_connection = create_engine().connect()"
]
},
{
Expand Down
21 changes: 21 additions & 0 deletions notebooks/notebook-basics/notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,27 @@
"db_connection2 = sa.create_engine(connection_url2).connect()"
]
},
{
"cell_type": "markdown",
"id": "082e240d-9480-46a2-a7da-33508423b8e9",
"metadata": {},
"source": [
"In addition, the SingleStoreDB Python package includes a wrapper `create_engine` function that \n",
"uses the `SINGLESTOREDB_URL` without having to specify `connection_url`."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4ec8e9a0-b45a-4f6f-b3a5-7b51a5a89ed0",
"metadata": {},
"outputs": [],
"source": [
"import singlestoredb as s2\n",
"\n",
"db_connection = s2.create_engine().connect()"
]
},
{
"cell_type": "markdown",
"id": "2dbc2854-2396-49e0-ae9f-5e68cc1e316c",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/semantic-search-with-openai-qa/notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@
"metadata": {},
"outputs": [],
"source": [
"import sqlalchemy as sa\n",
"import singlestoredb as s2\n",
"\n",
"db_connection = sa.create_engine(connection_url).connect()"
"db_connection = s2.create_engine().connect()"
]
},
{
Expand Down

0 comments on commit 5be2a78

Please sign in to comment.