MySQL
Create a MySQL connector with its real config fields, and understand the managed connection-test behavior for MySQL before you onboard data.
This page creates a saved mysql connector with its real configuration fields and explains exactly how the engine handles a MySQL connection so you know what to expect at each step. A mysql connector is a SQLAlchemy-based connection built on the mysql+pymysql driver.
Prerequisites: an API key and a base URL (see Authentication), and MySQL credentials — a host, a database, a user, and that user's password. Use https://api.algenta.ai for Algenta cloud, or your own origin such as http://localhost:8000 for a self-hosted deployment.
Set your credentials
Export your API key and base URL, and keep your MySQL password in its own variable so it never appears inline in shell history.
export ALGENTA_API_KEY="$ALGENTA_API_KEY"
export ALGENTA_BASE_URL="https://api.algenta.ai"
export MYSQL_PASSWORD="$MYSQL_PASSWORD"Verify the variables are set:
echo "${ALGENTA_API_KEY:?set ALGENTA_API_KEY}" >/dev/null && echo "key present"
echo "$ALGENTA_BASE_URL"
echo "${MYSQL_PASSWORD:?set MYSQL_PASSWORD}" >/dev/null && echo "password present"Expected result: three lines print without error — key present, your base URL, and password present. If any line errors, export the missing variable before continuing.
Confirm the engine accepts mysql
Ask the engine which connector types it supports and confirm mysql is in the list.
curl -s "$ALGENTA_BASE_URL/v1/connectors/types" \
-H "Authorization: Bearer $ALGENTA_API_KEY"Expected result: a JSON object with a types array that includes "mysql", for example {"types": ["mssql", "mysql", "postgres", ...]}.
Create the MySQL connector
POST /v1/connectors stores the connection name, type, and credentials, and returns the connector with status: "untested". Supply the discrete host, port, database, user, and password fields.
curl -s -X POST "$ALGENTA_BASE_URL/v1/connectors" \
-H "Authorization: Bearer $ALGENTA_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"name\": \"App MySQL\",
\"connector_type\": \"mysql\",
\"config\": {
\"host\": \"db.internal\",
\"port\": 3306,
\"database\": \"app\",
\"user\": \"reader\",
\"password\": \"$MYSQL_PASSWORD\"
}
}"If you already have a DSN, pass it as connection_string instead of the discrete fields:
curl -s -X POST "$ALGENTA_BASE_URL/v1/connectors" \
-H "Authorization: Bearer $ALGENTA_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"name\": \"App MySQL\",
\"connector_type\": \"mysql\",
\"config\": {
\"connection_string\": \"mysql+pymysql://reader:$MYSQL_PASSWORD@db.internal:3306/app\"
}
}"Capture the returned id:
export CONNECTOR_ID="$CONNECTOR_ID"Expected result: a 201 response with the connector id, "connector_type": "mysql", and "status": "untested". Credentials are encrypted at rest — the connector object never returns your config back to you, only its name, type, status, and last test result.
Verify the credentials from your own client
Because the engine does not run a managed test for MySQL, confirm the same host, database, user, and password work from a client you control. This is the check the engine would otherwise perform.
mysql -h db.internal -P 3306 -u reader -p"$MYSQL_PASSWORD" app -e "SELECT 1;"Expected result: the mysql client prints a single-row result for SELECT 1. If it errors, fix the host, port, database, user, or password before relying on the saved connector.
Other ways to create the connector
The same endpoint backs the de CLI and the Python SDK.
de connectors create connector.json # POST /v1/connectors from a JSON body
de connectors list # GET /v1/connectorsimport os
from decision_engine import AlgentaClient
client = AlgentaClient(
api_key=os.environ["ALGENTA_API_KEY"],
base_url="https://api.algenta.ai",
)
connector = client.create_connector(
name="App MySQL",
connector_type="mysql",
config={
"host": "db.internal",
"port": 3306,
"database": "app",
"user": "reader",
"password": os.environ["MYSQL_PASSWORD"],
},
)
print(connector.id, connector.status) # "untested"Troubleshooting
Next
Connect a databasePostgreSQLConnectors referenceLast updated
Was this helpful?