Skip to content

Commit 17994cc

Browse files
docs: update code samples with python designation (#256)
1 parent f52ba7e commit 17994cc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The connector itself creates connection objects by calling its `connect` method
5656
In the connector's `connect` method below, input your connection string as the first positional argument and the name of the database driver for the second positional argument. Insert the rest of your connection keyword arguments like user, password and database. You can also set the optional `timeout` or `ip_type` keyword arguments.
5757

5858
To use this connector with SQLAlchemy, use the `creator` argument for `sqlalchemy.create_engine`:
59-
```
59+
```python
6060
def getconn() -> pymysql.connections.Connection:
6161
conn: pymysql.connections.Connection = connector.connect(
6262
"project:region:instance",
@@ -74,7 +74,7 @@ pool = sqlalchemy.create_engine(
7474
```
7575

7676
The returned connection pool engine can then be used to query and modify the database.
77-
```
77+
```python
7878
# insert statement
7979
insert_stmt = sqlalchemy.text(
8080
"INSERT INTO my_table (id, title) VALUES (:id, :title)",
@@ -99,7 +99,7 @@ with pool.connect() as db_conn:
9999
### Specifying Public or Private IP
100100
The Cloud SQL Connector for Python can be used to connect to Cloud SQL instances using both public and private IP addresses. To specify which IP address to use to connect, set the `ip_type` keyword argument Possible values are `IPTypes.PUBLIC` and `IPTypes.PRIVATE`.
101101
Example:
102-
```
102+
```python
103103
connector.connect(
104104
"project:region:instance",
105105
"pymysql",
@@ -116,7 +116,7 @@ First, make sure to [configure your Cloud SQL Instance to allow IAM authenticati
116116
Now, you can connect using user or service account credentials instead of a password.
117117
In the call to connect, set the `enable_iam_auth` keyword argument to true and `user` to the email address associated with your IAM user.
118118
Example:
119-
```
119+
```python
120120
connector.connect(
121121
"project:region:instance",
122122
"pg8000",

0 commit comments

Comments
 (0)