Merge lp:~james-page/charm-helpers/bug1675220 into lp:charm-helpers

Proposed by James Page
Status: Merged
Merged at revision: 742
Proposed branch: lp:~james-page/charm-helpers/bug1675220
Merge into: lp:charm-helpers
Diff against target: 21 lines (+2/-2)
1 file modified
charmhelpers/contrib/database/mysql.py (+2/-2)
To merge this branch: bzr merge lp:~james-page/charm-helpers/bug1675220
Reviewer Review Type Date Requested Status
Chris MacNaughton (community) Approve
charmers Pending
Review via email: mp+324044@code.launchpad.net

Description of the change

Correctly quote database names to ensure that names generated from juju application names are acceptable.

For example 'neutron-api' contains a dash, which without quoting will cause a parsing failure.

To post a comment you must log in.
Revision history for this message
Chris MacNaughton (chris.macnaughton) wrote :

Looks good to me

review: Approve
Revision history for this message
Alex Kavanagh (ajkavanagh) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/database/mysql.py'
2--- charmhelpers/contrib/database/mysql.py 2017-03-03 11:09:33 +0000
3+++ charmhelpers/contrib/database/mysql.py 2017-05-15 10:30:38 +0000
4@@ -89,7 +89,7 @@
5 def create_database(self, db_name):
6 cursor = self.connection.cursor()
7 try:
8- cursor.execute("CREATE DATABASE {} CHARACTER SET UTF8"
9+ cursor.execute("CREATE DATABASE '{}' CHARACTER SET UTF8"
10 .format(db_name))
11 finally:
12 cursor.close()
13@@ -114,7 +114,7 @@
14 cursor = self.connection.cursor()
15 try:
16 # TODO: review for different grants
17- cursor.execute("GRANT ALL PRIVILEGES ON {}.* TO '{}'@'{}' "
18+ cursor.execute("GRANT ALL PRIVILEGES ON '{}'.* TO '{}'@'{}' "
19 "IDENTIFIED BY '{}'".format(db_name,
20 db_user,
21 remote_ip,

Subscribers

People subscribed via source and target branches