{"id":7267,"library":"google-cloud-sqlcommenter","title":"Google Cloud SQLCommenter","description":"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.","status":"active","version":"2.0.0","language":"python","source_language":"en","source_url":"https://github.com/googlecloudplatform/python-sqlcommenter","tags":["google-cloud","sql","observability","database","sqlcommenter","monitoring","tracing","sqlalchemy","django","flask"],"install":[{"cmd":"pip install google-cloud-sqlcommenter","lang":"bash","label":"Install the Google Cloud SQLCommenter meta-package"}],"dependencies":[],"imports":[{"wrong":"from google.cloud.sqlcommenter import patch","symbol":"patch","correct":"from google.cloud.sqlcommenter import patch"}],"quickstart":{"code":"from sqlalchemy import create_engine\nfrom sqlalchemy_sqlcommenter import patch\n\n# Configure a dummy engine for demonstration\nengine = create_engine('sqlite:///:memory:')\n\n# Patch the engine to enable SQL commenting\npatch(engine)\n\n# Execute a sample query\nwith engine.connect() as conn:\n    result = conn.execute('SELECT 1 + 1').scalar()\n    print(f\"Query result: {result}\")\n\n# In a real application, you would observe the SQL comments \n# in your database logs or APM/tracing tools.","lang":"python","description":"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."},"warnings":[{"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`).","message":"Version 2.0.0 of `google-cloud-sqlcommenter` (and its underlying `sqlalchemy-sqlcommenter` dependency) dropped support for Python 3.6 and 3.7.","severity":"breaking","affected_versions":"2.0.0+"},{"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.","message":"Do not attempt to import `patch` or other integration functions directly from the `google_cloud_sqlcommenter` package.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"SQL comments may not appear if the SQLAlchemy engine is patched too late or if unpatched engines are used.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Integration with existing OpenTelemetry setups requires careful configuration to avoid conflicts or ensure proper tracing context propagation.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'2.0.0':48 'act':26 'align':55 'augment':7 'better':20 'cloud':2,5,66 'current':45 'databas':23,69 'depend':58 'django':42,74 'e.g':39 'enabl':19 'environ':18 'featur':62 'flask':43,75 'framework':14,35 'framework-specif':34 'googl':1,4,65 'google-cloud':64 'inform':12 'instal':33 'integr':38,63 'major':57 'meta':11,30 'meta-packag':29 'monitor':71 'new':50,61 'observ':21,68 'oper':24 'packag':31 'releas':53 'run':17 'specif':36 'sql':8,67 'sqlalchemi':41,73 'sqlcomment':3,6,37,70 'statement':9 'trace':72 'typic':52 'updat':59 'version':46,51","created_at":"2026-04-16T13:50:55.483824+00:00","updated_at":"2026-04-16T13:50:55.483824+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmpnwj43k2r/venv/lib/python3.12/site-packages/google/__init__.py\", line 17, in <module>\n    __import__('pkg_resources').declare_namespace(__name__)\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^\nModuleNotFoundError: No module na"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.0.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://googlecloudplatform.github.io/cloud-sqlcommenter","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/google-cloud-sqlcommenter/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["gcp","observability","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}