Securely store and connect to MySQL databases with encrypted credentials.
pip install "pypangolin[mysql]"from pypangolin import PangolinClient
from pypangolin.assets.connections import MySQLAsset
from cryptography.fernet import Fernet
client = PangolinClient(uri="http://localhost:8080")
client.login("username", "password")
# User-managed encryption (recommended)
encryption_key = Fernet.generate_key().decode('utf-8')
MySQLAsset.register(
client,
catalog="data_sources",
namespace="databases",
name="prod_mysql",
connection_string="mysql://db.example.com:3306/production",
credentials={
"username": "dbuser",
"password": "securepassword123"
},
encryption_key=encryption_key,
store_key=False,
description="Production MySQL database"
)import os
encryption_key = os.getenv("DB_ENCRYPTION_KEY")
conn = MySQLAsset.connect(
client,
catalog="data_sources",
namespace="databases",
name="prod_mysql",
encryption_key=encryption_key
)
cursor = conn.cursor()
cursor.execute("SELECT DATABASE()")
print(cursor.fetchone())
cursor.close()
conn.close()mysql://host:port/database
mysql://host/database # Default port 3306
Same as PostgreSQL - use user-managed keys for production, store keys in secrets managers, and leverage Pangolin RBAC.