wuttamess.mysql¶
MySQL DB utilities
- wuttamess.mysql.create_db(c, name, checkfirst=True, user=None)[source]¶
Create a MySQL database.
- Parameters:
c – Fabric connection.
name – Name of the database to create.
checkfirst – If true (the default), first call
db_exists()and skip creating if already present. If false, then try to create DB with no check.user – Optional user which should be granted full access to the database. If specified, should include username and host, e.g.
poser@localhost. See alsogrant_access().
- wuttamess.mysql.create_user(c, name, host='localhost', password=None, checkfirst=True)[source]¶
Create a MySQL user account.
- Parameters:
c – Fabric connection.
name – Username to create.
host – Host portion for the MySQL user account; default is
localhost.password – Optional password for the new user. If set, will call
set_user_password().checkfirst – If true (the default), first call
user_exists()and skip creating if already present. If false, then try to create user with no check.
- wuttamess.mysql.db_exists(c, name)[source]¶
Determine if a given MySQL database exists.
- Parameters:
c – Fabric connection.
name – Name of the database to check for.
- Returns:
Trueif database exists, elseFalse.
- wuttamess.mysql.drop_db(c, name, checkfirst=True)[source]¶
Drop a MySQL database.
- Parameters:
c – Fabric connection.
name – Name of the database to drop.
checkfirst – If true (the default), first call
db_exists()and skip dropping if not present. If false, then try to drop DB with no check.
- wuttamess.mysql.grant_access(c, dbname, user)[source]¶
Grant full access to the given database for the given user.
- Parameters:
c – Fabric connection.
dbname – Name of the database to which access should be granted.
user – MySQL user which should be granted access. Must specify username and host, e.g.
poser@localhost.
- wuttamess.mysql.set_user_password(c, name, password, host='localhost')[source]¶
Set the password for a MySQL user account.
- Parameters:
c – Fabric connection.
name – Username whose password is to be set.
password – New password for the user.
host – Host portion for the MySQL user account; default is
localhost.