Test MySQL database connectivity and execute queries for Ebury Brazil databases. Supports Cloud SQL and remote MySQL instances. Use when user says "test MySQL connection", "connect to database", "query MySQL", "check database access", "test Cloud SQL". Configured for ebb-money-flows-dev (34.39.195.206). Do NOT use for PostgreSQL (different driver needed) or production writes (read-only recommended).
Test MySQL database connectivity and execute queries safely.
Use this skill when:
Do NOT use for:
pip install pymysql python-dotenv
Create .env file:
# Database connection
MYSQL_HOST=34.39.195.206
MYSQL_PORT=3306
MYSQL_USER=app_user
MYSQL_PASSWORD=secure_password
MYSQL_DATABASE=ebb_money_flows
# Optional
MYSQL_CHARSET=utf8mb4
MYSQL_CONNECT_TIMEOUT=10
For Google Cloud SQL:
# Option 1: Public IP with authorized networks
MYSQL_HOST=34.39.195.206
MYSQL_USER=app_user
MYSQL_PASSWORD=password
# Option 2: Cloud SQL Proxy
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306
# Run proxy: cloud_sql_proxy -instances=PROJECT:REGION:INSTANCE=tcp:3306
cd skills/mysql_connect/
python main.py
$ python main.py
🔌 Testing MySQL connection...
Host: 34.39.195.206:3306
User: app_user
Database: ebb_money_flows
✓ Connection successful!
Server version: 8.0.31-google
Connection ping: OK
Testing query execution...
✓ Query executed successfully
Connection details:
- Host: 34.39.195.206
- Port: 3306
- Database: ebb_money_flows
- Character Set: utf8mb4
- Connection ID: 12345
Verifies:
# Example in main.py
cursor = connection.cursor()
# Check database version
cursor.execute("SELECT VERSION()")
version = cursor.fetchone()
print(f"MySQL version: {version[0]}")
# List tables
cursor.execute("SHOW TABLES")
tables = cursor.fetchall()
for table in tables:
print(f" - {table[0]}")
# Count records
cursor.execute("SELECT COUNT(*) FROM users")
count = cursor.fetchone()
print(f"Total users: {count[0]}")
# Ping connection
connection.ping(reconnect=True)
# Get connection info
print(f"Thread ID: {connection.thread_id()}")
print(f "Character set: {connection.character_set_name()}")
import pymysql
from dotenv import load_dotenv
import os
load_dotenv()