# MySQL Tasks
This module contains a collection of tasks for interacting with MySQL databases via the pymysql library.
# MySQLExecute
class
prefect.tasks.mysql.mysql.MySQLExecute
(db_name, user, password, host, port=3306, query=None, commit=False, charset="utf8mb4", **kwargs)[source]Task for executing a query against a MySQL database.
Args:
db_name (str)
: name of MySQL databaseuser (str)
: user name used to authenticatepassword (str)
: password used to authenticatehost (str)
: database host addressport (int, optional)
: port used to connect to MySQL database, defaults to 3307 if not providedquery (str, optional)
: query to execute against databasecommit (bool, optional)
: set to True to commit transaction, defaults to falsecharset (str, optional)
: charset you want to use (defaults to utf8mb4)**kwargs (Any, optional)
: additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.mysql.mysql.MySQLExecute.run (query, commit=False, charset="utf8mb4")[source] |
Task run method. Executes a query against MySQL database.
|
# MySQLFetch
class
prefect.tasks.mysql.mysql.MySQLFetch
(db_name, user, password, host, port=3306, fetch="one", fetch_count=10, query=None, commit=False, charset="utf8mb4", cursor_type="cursor", **kwargs)[source]Task for fetching results of query from MySQL database.
Args:
db_name (str)
: name of MySQL databaseuser (str)
: user name used to authenticatepassword (str)
: password used to authenticatehost (str)
: database host addressport (int, optional)
: port used to connect to MySQL database, defaults to 3307 if not providedfetch (str, optional)
: one of "one" "many" or "all", used to determine how many results to fetch from executed queryfetch_count (int, optional)
: if fetch = 'many', determines the number of results to fetch, defaults to 10query (str, optional)
: query to execute against databasecommit (bool, optional)
: set to True to commit transaction, defaults to falsecharset (str, optional)
: charset of the query, defaults to "utf8mb4"cursor_type (Union[str, Callable], optional)
: The cursor type to use. Can be'cursor'
(the default),'dictcursor'
,'sscursor'
,'ssdictcursor'
, or a full cursor class.**kwargs (Any, optional)
: additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.mysql.mysql.MySQLFetch.run (query, fetch="one", fetch_count=10, commit=False, charset="utf8mb4", cursor_type="cursor")[source] |
Task run method. Executes a query against MySQL database and fetches results.
|
This documentation was auto-generated from commit 59ae220
on April 9, 2021 at 15:46 UTC