skillfed

cloud-sql-python-connector

Google Cloud SQL Python Connector library

cloud-sql-python-connector v1.21.0 8.0M downloads/30d#1,677 on PyPI344
Permissive license Apache-2.0 Active released

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-connector

uv

uv add cloud-sql-python-connector

poetry

poetry add cloud-sql-python-connector

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9

Tags

cloud sql python connectorgoogle cloud sql authenticationiam database connectionscloud sql tls encryptionmanaged cloud database proxyserverless cloud sql accessgoogle cloud sql driver
google-cloudiam-authtls-encryption

More Database packages

psycopg2-binary

psycopg2-binary is a PostgreSQL database…

copyleft · top 1,000 on PyPI

redis

Python client library for connecting to and…

permissive · top 1,000 on PyPI

ydb

YDB Python SDK is the official client library…

permissive · top 1,000 on PyPI

snowflake-connector-python

Connects Python applications to Snowflake data…

permissive · top 1,000 on PyPI

sqlparse

sqlparse tokenizes SQL text into a tree of…

permissive · top 1,000 on PyPI

dbt-adapters

Provides base adapter protocols and shared…

permissive · top 1,000 on PyPI

google-cloud-alloydb-connector

Provides secure, IAM-based connections to…

permissive · top 15,000 on PyPI

sqlalchemy-rdsiam

Provides SQLAlchemy dialects for connecting to…

unclear · top 15,000 on PyPI

ipython-sql

Adds SQL magic commands to IPython and Jupyter…

permissive · top 15,000 on PyPI

gcloud-aio-auth

Provides asyncio-compatible and threadsafe…

permissive · top 1,000 on PyPI

databricks-sql-connector

A Python client library that connects to…

permissive · top 1,000 on PyPI

redshift-connector

redshift_connector is a Python database driver…

permissive · top 1,000 on PyPI

sqlalchemy-pytds

Provides a SQLAlchemy dialect for connecting to…

permissive · top 5,000 on PyPI

sqlalchemy-aurora-data-api

Provides a SQLAlchemy dialect for accessing…

permissive · top 15,000 on PyPI

google-cloud-iam

Provides a Python client library for Google…

permissive · top 5,000 on PyPI

sqlalchemy-databricks

Provides a SQLAlchemy dialect that connects to…

permissive · top 15,000 on PyPI