Migrate Python Connector Examples#215
Closed
anwesham-lab wants to merge 1 commit intoaws-samples:mainfrom
Closed
Conversation
Adding the examples using the Aurora DSQL Python Connector (with the smoke tests), since using the connector is the preferred method and offers a more seamless user experience. This is the promoted default path on the documentation, and the samples should be consistent with this. Moved the boto3 examples to an `alternatives`, for use as needed. This also offers agentic benefits, as most agents are now able to leverage a single search space and cross-example contex can stay intact. It creates stronger retrieval since all the variants sit in the same space, and agents will quickly be able to locate the best example since by default, the documentation normally points to the samples repository.
Benjscho
reviewed
Dec 15, 2025
| [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services). | ||
|
|
||
|
|
||
| ## TLS connection configuration |
Contributor
There was a problem hiding this comment.
Do we need a big section on this? While it helps with quicker conns feels like excess detail
Comment on lines
+14
to
+17
| * When connecting as an **admin user**, the example uses the `public` schema and generates an admin authentication | ||
| token. | ||
| * When connecting as a **non-admin user**, the example uses a custom `myschema` schema and generates a standard | ||
| authentication token. |
Contributor
There was a problem hiding this comment.
We repeat this below, needed?
Comment on lines
+110
to
+135
| #### Environment Cluster Details | ||
|
|
||
| Set environment variables for your cluster details: | ||
|
|
||
| ```bash | ||
| # e.g. "admin" | ||
| export CLUSTER_USER="<your user>" | ||
|
|
||
| # e.g. "foo0bar1baz2quux3quuux4.dsql.us-east-1.on.aws" | ||
| export CLUSTER_ENDPOINT="<your endpoint>" | ||
|
|
||
| # e.g. "us-east-1" | ||
| export REGION="<your region>" | ||
| ``` | ||
|
|
||
| #### Run the example: | ||
|
|
||
| ```bash | ||
| # Run example directly | ||
| python src/example.py | ||
|
|
||
| # Run example using pytest | ||
| pytest ./test/test_example.py | ||
|
|
||
| # Run all using pytest | ||
| pytest ./test |
Contributor
There was a problem hiding this comment.
Can we show them a one liner with the env vars set? Feels like the tests are excessive for someone looking for the example
| """ | ||
| ) | ||
|
|
||
| # Insert some rows |
| try: | ||
| async with pool.acquire() as conn: | ||
| result = await conn.fetchval("SELECT 1") | ||
| assert result == 1 |
Contributor
There was a problem hiding this comment.
Does this give a confusing err if they can't connect?
| if not os.path.isfile(ssl_cert_path): | ||
| raise FileNotFoundError(f"SSL certificate file not found: {ssl_cert_path}") | ||
|
|
||
| await connect_with_pool(cluster_user, cluster_endpoint, region) |
Contributor
There was a problem hiding this comment.
Should we have a more extended query than the health check?
| python src/example.py | ||
|
|
||
| # Run example using pytest | ||
| pytest ./test/test_example.py |
Contributor
There was a problem hiding this comment.
Same here, not sure if we need to demo how to run tests
| kwargs=conn_params, # Pass params as kwargs | ||
| min_size=2, | ||
| max_size=10, | ||
| max_lifetime=3300, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding the examples using the Aurora DSQL Python Connector (with the
smoke tests), since using the connector is the preferred method and
offers a more seamless user experience. This is the promoted default
path on the documentation, and the samples should be consistent with
this. Moved the boto3 examples to an
alternatives, for use asneeded.
This also offers agentic benefits, as most agents are now able to
leverage a single search space and cross-example contex can stay
intact. It creates stronger retrieval since all the variants sit in the
same space, and agents will quickly be able to locate the best example
since by default, the documentation normally points to the samples
repository.
By submitting this pull request, I confirm that my contribution is made under
the terms of the MIT-0 license.
Thank you for your contribution!