# Cloud SQL Client Libraries Google Cloud provides client libraries and connectors to simplify connecting to Cloud SQL from various programming languages. ## Getting Started Ensure you have the latest version of the Google Cloud SDK installed and authenticated. [Install Google Cloud SDK](https://cloud.google.com/sdk/docs/install) ### Language Connectors The Cloud SQL Language Connectors (Python, Java, Go, Node.js) provide a secure way to connect to the Cloud SQL instance without managing IP allowlists or SSL certificates. #### Python - **Installation for a Cloud SQL for PostgreSQL instance:** ```bash pip install "cloud-sql-python-connector[pg8000]" ``` - **Usage Example:** ```python from google.cloud.sql.connector import Connector connector = Connector() def getconn(): conn = connector.connect( "project:region:instance", "pg8000", user="my-user", password="my-password", db="my-db" ) return conn ``` #### Java - **Maven Dependencies:** The recommended method is to use the Cloud SQL JDBC Socket Factory. Add the BOM to your `` section: ```xml com.google.cloud.sql jdbc-socket-factory-bom 1.18.0 pom import ``` Then add dependencies for your database: * **PostgreSQL:** ```xml org.postgresql postgresql 42.7.3 com.google.cloud.sql postgres-socket-factory ``` * **MySQL:** ```xml com.mysql mysql-connector-j 8.0.33 com.google.cloud.sql mysql-socket-factory-connector-j-8 ``` #### Node.js (TypeScript) - **Installation:** ```bash npm install @google-cloud/cloud-sql-connector ``` #### Go - **Installation:** ```bash go get cloud.google.com/go/cloudsqlconn ``` ## Cloud SQL Admin API To manage Cloud SQL resources (e.g., list instances) programmatically, use the `sqladmin` libraries. - [Cloud SQL Admin API Overview](https://docs.cloud.google.com/sql/docs/mysql/admin-api)