Chalk supports MySQL as a SQL source. You can configure the MySQL-specific options using the MySQLSource init args, or configure the source through your dashboard, and reference the source in your code.

Adding MySQL

On the dashboard, you can plug in the configuration for your MySQL database:

Add MySQL

Add a MySQL integration.

MySQL
Environment

Learn more about Chalk's MySQL Integration

Integrations Setup

After configuring your MySQL integration in the dashboard, define your data sources in Python:

from chalk.sql import MySQLSource

risk = MySQLSource(name="RISK")
marketing = MySQLSource(name="MARKETING")

Then reference them in SQL file resolvers using the name parameter. For example, to query from the RISK source:

-- type: online
-- resolves: User
-- source: RISK
SELECT id, credit_score FROM users

And to query from the MARKETING source:

-- type: online
-- resolves: User
-- source: MARKETING
SELECT id, email, campaign_status FROM users
Named integrations inject environment variables with the standard names prefixed by the integration name. For example, if your integration is called RISK, then the variable MYSQL_HOST will be injected as RISK_MYSQL_HOST.