From f61934e3e128f4dab8f7429d140c88f052edf0ce Mon Sep 17 00:00:00 2001 From: pauls-FB <96253739+pauls-FB@users.noreply.github.com> Date: Mon, 19 Jun 2023 11:05:58 -0600 Subject: [PATCH 1/2] Update Connecting_and_queries.rst Add context manager to connection example --- docsrc/Connecting_and_queries.rst | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/docsrc/Connecting_and_queries.rst b/docsrc/Connecting_and_queries.rst index 0536ff6d50f..7fb3c87f089 100644 --- a/docsrc/Connecting_and_queries.rst +++ b/docsrc/Connecting_and_queries.rst @@ -26,6 +26,7 @@ To get started, follow the steps below: from firebolt.db import connect from firebolt.client import DEFAULT_API_URL + from firebolt.client.auth import UsernamePassword .. _connecting_with_credentials_example: @@ -66,13 +67,11 @@ To get started, follow the steps below: engine_name = "your_engine" database_name = "your_database" - connection = connect( - engine_name=engine_name, - database=database_name, - username=username, - password=password, - ) - + with connect( + engine_name=engine_name, + database=database_name, + auth=UsernamePassword(username, password), + ) as connection: cursor = connection.cursor() @@ -103,16 +102,16 @@ To get started, follow the steps below: load_dotenv() - connection = connect( - username=os.getenv('FIREBOLT_USER'), - password=os.getenv('FIREBOLT_PASSWORD'), + with connect( + auth=UsernamePassword( + os.getenv("FIREBOLT_USER"), + os.getenv("FIREBOLT_PASSWORD") + ) engine_name=os.getenv('FIREBOLT_ENGINE'), database=os.getenv('FIREBOLT_DB') - ) - + ) as connection: cursor = connection.cursor() - **3. Execute commands using the cursor** The ``cursor`` object can be used to send queries and commands to your Firebolt From 9632668d7a05cd570a4ddc19364e7abb70b5ca00 Mon Sep 17 00:00:00 2001 From: pauls-FB <96253739+pauls-FB@users.noreply.github.com> Date: Tue, 20 Jun 2023 06:56:24 -0600 Subject: [PATCH 2/2] Update Connecting_and_queries.rst Indented lines as Petro described --- docsrc/Connecting_and_queries.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docsrc/Connecting_and_queries.rst b/docsrc/Connecting_and_queries.rst index 7fb3c87f089..aae9b530ce8 100644 --- a/docsrc/Connecting_and_queries.rst +++ b/docsrc/Connecting_and_queries.rst @@ -72,7 +72,7 @@ To get started, follow the steps below: database=database_name, auth=UsernamePassword(username, password), ) as connection: - cursor = connection.cursor() + cursor = connection.cursor() * **Use an .env file** @@ -110,7 +110,7 @@ To get started, follow the steps below: engine_name=os.getenv('FIREBOLT_ENGINE'), database=os.getenv('FIREBOLT_DB') ) as connection: - cursor = connection.cursor() + cursor = connection.cursor() **3. Execute commands using the cursor**