0

I'm trying to upload a CSV file to a database in my SQL instance on Google Cloud SQL, and I'm confused as to how exactly am I supposed to go about this project.

my code so far:

import pandas as pd
from google.cloud.sql.connector import connector

read_file = pd.read_csv(PATH TO CSV FILE)
df = pd.DataFrame(read_file, columns=['date', 'current_market_queries',
                                      'last_year_market_queries'])

conn = connector.connect("project:region:instance", "pymysql",
                         host="34.101.244.253", db="insights", user="...",
                         password="...", check_hostname=False)

What exactly are the parameters for the connect method? What's google standard? Is the user supposed to be the email of my Google Cloud account?

Furthermore, is there a link to a website that lists the methods of this google.cloud.sql.connector Python library?

2
  • Do you just want to push some data to your database table? Commented Jul 13, 2021 at 5:44
  • Yes, preferably Commented Jul 14, 2021 at 7:34

1 Answer 1

1

Thanks for the question! Currently, most of our documentation is in the project README and on this Google Cloud documentation page. The user in the connect method will be a user in your Cloud SQL database. This can be an email if you have IAM authentication enabled, but in most cases it will just be the user and password you use to authenticate into the database.

The connect method returns a DB-API 2.0 connection object which can be used to insert each row of your pandas dataframe.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.