Registry / gcp / google-cloud-sqlcommenter

google-cloud-sqlcommenter

JSON →
library2.0.0pypypiunverified

Google Cloud SQLCommenter augments SQL statements with meta information about frameworks and the running environment, enabling better observability for database operations. It acts as a meta-package to install framework-specific SQLCommenter integrations (e.g., for SQLAlchemy, Django, Flask). The current version is 2.0.0, with new versions typically released to align with major dependency updates or new feature integrations.

pip install google-cloud-sqlcommenter
INSTALL
IMPORT
SIG · GOOGLE-CLOUD-SQLCO
G
google-cloud-sqlcommenter
gcppythonv2.0.0
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

patch
from google.cloud.sqlcommenter import patch
from google.cloud.sqlcommenter import patch

This quickstart demonstrates how to integrate SQLCommenter with SQLAlchemy. After installing `google-cloud-sqlcommenter`, import `patch` from `sqlalchemy_sqlcommenter` and apply it to your SQLAlchemy engine. All subsequent queries through that engine will be augmented with comments.

from sqlalchemy import create_engine from sqlalchemy_sqlcommenter import patch # Configure a dummy engine for demonstration engine = create_engine('sqlite:///:memory:') # Patch the engine to enable SQL commenting patch(engine) # Execute a sample query with engine.connect() as conn: result = conn.execute('SELECT 1 + 1').scalar() print(f"Query result: {result}") # In a real application, you would observe the SQL comments # in your database logs or APM/tracing tools.
Debug
Known issues
breakingVersion 2.0.0 of `google-cloud-sqlcommenter` (and its underlying `sqlalchemy-sqlcommenter` dependency) dropped support for Python 3.6 and 3.7.
fix
Upgrade your Python environment to 3.8 or newer. If you must use Python 3.6 or 3.7, pin your `google-cloud-sqlcommenter` dependency to a 1.x version (e.g., `google-cloud-sqlcommenter<2.0`).
affects: 2.0.0+
gotchaDo not attempt to import `patch` or other integration functions directly from the `google_cloud_sqlcommenter` package.
fix
Always import integration functions from the specific ORM integration package, such as `sqlalchemy_sqlcommenter` for SQLAlchemy, `django_sqlcommenter` for Django, etc. `google-cloud-sqlcommenter` is a meta-package.
affects: All versions
gotchaSQL comments may not appear if the SQLAlchemy engine is patched too late or if unpatched engines are used.
fix
Ensure `sqlalchemy_sqlcommenter.patch(engine)` is called immediately after creating your `sqlalchemy.engine` object and before any connections are made or queries executed through that engine. If using multiple engines, patch each one.
affects: All versions
gotchaIntegration with existing OpenTelemetry setups requires careful configuration to avoid conflicts or ensure proper tracing context propagation.
fix
Refer to the official documentation on how SQLCommenter's OpenTelemetry integration interacts with your existing setup. Ensure your OpenTelemetry tracer provider and exporter are configured correctly to receive spans from SQLCommenter.
affects: All versions
Upgrade
Version history
2.0.0latest on PyPI · released Aug 18, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources
google-cloud-sqlcommenter — pip install google-cloud-sqlcommenter · libregistry