Using the Cloud SQL Python connector you can run a script that looks something like this
import os
from google.cloud.sql.connector import connector
conn = connector.connect(
os.getenv("INSTANCE_CONNECTION_NAME"),
"pg8000",
user=os.getenv("DB_USER"),
password=os.getenv("DB_PASSWORD"),
db=os.getenv("DB_NAME")
)
cursor = conn.cursor()
cursor.execute("SELECT * from my_table")
result = cursor.fetchall()
for row in result:
print(row)