Implementation
This handler was implemented using the existing MindsDB handlers for MySQL, PostgreSQL and SQL Server. The required arguments to establish a connection are,host
: the host name or IP address of the Google Cloud SQL instance.port
: the TCP/IP port of the Google Cloud SQL instance.user
: the username used to authenticate with the Google Cloud SQL instance.password
: the password to authenticate the user with the Google Cloud SQL instance.database
: the database name to use when connecting with the Google Cloud SQL instance.db_engine
: the database engine of the Google Cloud SQL instance. This can take one of three values: ‘mysql’, ‘postgresql’ or ‘mssql’.
If you installed MindsDB locally via pip, you need to install all handler dependencies manually. To do so, go to the
handler’s folder (mindsdb/integrations/handlers/cloud_sql_handler) and run this command:
pip install -r requirements.txt
.Usage
In order to make use of this handler and connect to the Google Cloud SQL instance, you need to create a datasource with the following syntax:- Go to the Cloud SQL Instances page.
- Click on the instance you want to add authorized networks to.
- Click on the Connections tab.
- Click on Networking tab.
- Click on Add network.
- Enter the IP address of the machine you want to connect from.
18.220.205.95 3.19.152.46 52.14.91.162
You can use this established connection to query your table as follows: