cloud-sql-python-connector
Google Cloud SQL Python Connector library
What it is and what it does
The Cloud SQL Python Connector is a Google-maintained library that handles secure, IAM-authenticated connections to Cloud SQL instances without requiring SSL certificates or IP allowlisting. It wraps database drivers (pymysql, pg8000, asyncpg, pytds), intercepting connection requests to establish encrypted TLS 1.3 tunnels through Google's infrastructure using your application's IAM credentials.
The connector is designed to work alongside connection pooling libraries to manage connection reuse and reduce overhead. It supports both eager (background refresh) and lazy refresh strategies for credential management, making it suitable for serverless environments like Cloud Run and Cloud Functions where CPU throttling occurs outside request contexts. You initialize a Connector object, call its connect method with your instance details, and the library handles all authentication and encryption transparently.
Use it for:
- Connect Python applications on Cloud Run or Cloud Functions to Cloud SQL without managing certificates or firewall rules
- Migrate from Cloud SQL Auth Proxy to a native Python solution with IAM-based access control
- Build multi-tenant applications where each tenant's database access is controlled via IAM roles
- Use IAM database authentication to avoid storing database passwords in application code or secrets
- Establish encrypted connections to Cloud SQL from on-premises or hybrid environments using service account credentials
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides IAM-based authentication and encrypted connections to Google Cloud SQL instances from Python, handling TLS encryption and identity verification without requiring SSL certificates.
Yes. This is the official, actively maintained connector for Python applications accessing Cloud SQL on Google Cloud. It eliminates certificate management and IP allowlisting overhead while providing IAM-based security. Install it if you are running Python on Google Cloud and need Cloud SQL connectivity.
Install
cloud-sql-python-connector on PyPI
pip
pip install cloud-sql-python-connectoruv
uv add cloud-sql-python-connectorpoetry
poetry add cloud-sql-python-connectorInstalling cloud-sql-python-connector
Before you install
Low friction install with a pure-Python wheel. Actively maintained with a recent release (21 days old) and a stable codebase (344 stars, last commit 2026-08-13). Eight runtime dependencies are all well-established libraries.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions.
Quickstart
pip install "cloud-sql-python-connector[pymysql]"
from google.cloud.sql.connector import Connector
connector = Connector()
conn = connector.connect(
"project:region:instance",
"pymysql",
user="my-user",
password="my-password",
db="my-db-name"
)
connector.close()
Requires IAM principal with Cloud SQL Client role and Cloud SQL Admin API enabled in your Google Cloud Project; uses Application Default Credentials for authentication.
Verify before relying
- Performance characteristics and connection overhead compared to direct SSL certificate management
- Support for connection pooling libraries beyond those mentioned in the description
- Behavior and latency in environments with intermittent network connectivity
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 8 — aiohttp, cryptography, dnspython, Requests, google-auth, grpcio, protobuf, googleapis-common-protos |
| Maintenance | actively maintained — 21 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 7,971,363/month — #1,677 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cloud_sql_python_connector-1.21.0-py3-none-any.whl
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
google-cloud-alloydb-connectorProvides secure, IAM-based connections to…
permissive · top 15,000 on PyPI
sqlalchemy-rdsiamProvides SQLAlchemy dialects for connecting to…
unclear · top 15,000 on PyPI
ipython-sqlAdds SQL magic commands to IPython and Jupyter…
permissive · top 15,000 on PyPI
gcloud-aio-authProvides asyncio-compatible and threadsafe…
permissive · top 1,000 on PyPI
databricks-sql-connectorA Python client library that connects to…
permissive · top 1,000 on PyPI
redshift-connectorredshift_connector is a Python database driver…
permissive · top 1,000 on PyPI
sqlalchemy-pytdsProvides a SQLAlchemy dialect for connecting to…
permissive · top 5,000 on PyPI
sqlalchemy-aurora-data-apiProvides a SQLAlchemy dialect for accessing…
permissive · top 15,000 on PyPI
google-cloud-iamProvides a Python client library for Google…
permissive · top 5,000 on PyPI
sqlalchemy-databricksProvides a SQLAlchemy dialect that connects to…
permissive · top 15,000 on PyPI