MySQL (dagster-mysql)
- dagster_mysql.MySQLResource ResourceDefinition
Resource for interacting with a MySQL database. Wraps an underlying mysql.connector connection.
Examples:
from dagster import Definitions, asset, EnvVar
from dagster_mysql import MySQLResource
@asset
def my_table(mysql: MySQLResource):
with mysql.get_connection() as conn:
with conn.cursor() as cur:
cur.execute("SELECT * FROM table;")
defs = Definitions(
assets=[my_table],
resources={
"mysql": MySQLResource(
host="localhost",
port=3306,
user="root",
password=EnvVar("MYSQL_PASSWORD")
)
}
)
class
dagster_mysql.MySQLEventLogStorageMySQL-backed event log storage.
Users should not directly instantiate this class; it is instantiated by internal machinery when
dagster-webserver
anddagster-graphql
load, based on the values in thedagster.yaml
file in$DAGSTER_HOME
. Configuration of this class should be done by setting values in that file.dagster.yaml
event_log_storage:
module: dagster_mysql.event_log
class: MySQLEventLogStorage
config:
mysql_db:
username: { username }
password: { password }
hostname: { hostname }
db_name: { db_name }
port: { port }Note that the fields in this config are
StringSource
andIntSource
and can be configured from environment variables.
class
dagster_mysql.MySQLRunStorageMySQL-backed run storage.
Users should not directly instantiate this class; it is instantiated by internal machinery when
dagster-webserver
anddagster-graphql
load, based on the values in thedagster.yaml
file in$DAGSTER_HOME
. Configuration of this class should be done by setting values in that file.dagster.yaml
run_storage:
module: dagster_mysql.run_storage
class: MySQLRunStorage
config:
mysql_db:
username: { username }
password: { password }
hostname: { hostname }
db_name: { database }
port: { port }Note that the fields in this config are
StringSource
andIntSource
and can be configured from environment variables.
class
dagster_mysql.MySQLScheduleStorageMySQL-backed run storage.
Users should not directly instantiate this class; it is instantiated by internal machinery when
dagster-webserver
anddagster-graphql
load, based on the values in thedagster.yaml
file in$DAGSTER_HOME
. Configuration of this class should be done by setting values in that file.dagster.yaml
schedule_storage:
module: dagster_mysql.schedule_storage
class: MySQLScheduleStorage
config:
mysql_db:
username: { username }
password: { password }
hostname: { hostname }
db_name: { db_name }
port: { port }Note that the fields in this config are
StringSource
andIntSource
and can be configured from environment variables.