From 31acf33465858a701165b184aee3e341b22421e4 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 15 Jul 2018 17:47:03 -0500 Subject: [PATCH] Add `mysql.script()` convenience function --- rattail_fabric/mysql.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rattail_fabric/mysql.py b/rattail_fabric/mysql.py index d6d65bc..7183e0e 100644 --- a/rattail_fabric/mysql.py +++ b/rattail_fabric/mysql.py @@ -154,6 +154,13 @@ def sql(sql, database=''): return sudo("mysql --execute='{}' --batch --skip-column-names {}".format(sql, database)) +def script(path, database=''): + """ + Execute a SQL script against the given database. + """ + sudo('mysql {} < {}'.format(database, path)) + + def download_db(name, destination=None): """ Download a database from the "current" server.