Tweak mysql.sql()
to allow suppressing echo and output
also install default-mysql-server now, per latest debian
This commit is contained in:
parent
f787b3ad79
commit
039af4b394
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2018 Lance Edgar
|
||||
# Copyright © 2010-2019 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -24,8 +24,6 @@
|
|||
Fabric Library for MySQL
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
from rattail_fabric2 import apt, make_deploy
|
||||
|
||||
|
||||
|
@ -36,7 +34,7 @@ def install(c):
|
|||
"""
|
||||
Install the MySQL database service
|
||||
"""
|
||||
apt.install(c, 'mysql-server')
|
||||
apt.install(c, 'default-mysql-server')
|
||||
|
||||
|
||||
def user_exists(c, name, host='localhost'):
|
||||
|
@ -54,9 +52,8 @@ def create_user(c, name, host='localhost', password=None, checkfirst=True):
|
|||
if not checkfirst or not user_exists(c, name, host):
|
||||
sql(c, "CREATE USER '{}'@'{}';".format(name, host))
|
||||
if password:
|
||||
# with hide('running'):
|
||||
sql(c, "SET PASSWORD FOR '{}'@'{}' = PASSWORD('{}');".format(
|
||||
name, host, password))
|
||||
name, host, password), hide=True, echo=False)
|
||||
|
||||
|
||||
def db_exists(c, name):
|
||||
|
@ -107,7 +104,7 @@ def table_exists(c, tblname, dbname):
|
|||
return name == tblname
|
||||
|
||||
|
||||
def sql(c, sql, database=''):
|
||||
def sql(c, sql, database='', **kwargs):
|
||||
"""
|
||||
Execute some SQL.
|
||||
"""
|
||||
|
@ -116,7 +113,8 @@ def sql(c, sql, database=''):
|
|||
sql = sql.replace("'", "'\"'\"'")
|
||||
# note, we force sudo "as root" to ensure -H flag is used
|
||||
# (which allows us to leverage /root/.my.cnf config file)
|
||||
return c.sudo("mysql --execute='{}' --batch --skip-column-names {}".format(sql, database), user='root')
|
||||
kwargs['user'] = 'root'
|
||||
return c.sudo("mysql --execute='{}' --batch --skip-column-names {}".format(sql, database), **kwargs)
|
||||
|
||||
|
||||
def download_db(c, name, destination=None):
|
||||
|
|
Loading…
Reference in a new issue