Skip to content

Migrate Python Connector Examples#215

Closed
anwesham-lab wants to merge 1 commit intoaws-samples:mainfrom
anwesham-lab:main
Closed

Migrate Python Connector Examples#215
anwesham-lab wants to merge 1 commit intoaws-samples:mainfrom
anwesham-lab:main

Conversation

@anwesham-lab
Copy link
Copy Markdown
Contributor

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.

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!

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.
@anwesham-lab anwesham-lab requested review from a team and Benjscho December 15, 2025 04:43
Copy link
Copy Markdown
Contributor

@Benjscho Benjscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, a few nits

Comment thread python/asyncpg/README.md
[AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).


## TLS connection configuration
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a big section on this? While it helps with quicker conns feels like excess detail

Comment thread python/asyncpg/README.md
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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We repeat this below, needed?

Comment thread python/asyncpg/README.md
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: row 😛

try:
async with pool.acquire() as conn:
result = await conn.fetchval("SELECT 1")
assert result == 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a more extended query than the health check?

Comment thread python/psycopg/README.md
python src/example.py

# Run example using pytest
pytest ./test/test_example.py
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be up to 55 mins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants