postgresql_schema: use query_params with cursor object (#65679)

This commit is contained in:
Andrew Klychkov 2019-12-10 11:41:23 +03:00 committed by Abhijit Menon-Sen
parent 2e82989b3b
commit c791f916d3
2 changed files with 6 additions and 4 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- postgresql_schema - use query parameters with cursor object (https://github.com/ansible/ansible/pull/65679).

View file

@ -165,15 +165,15 @@ def set_owner(cursor, schema, owner):
def get_schema_info(cursor, schema):
query = ("SELECT schema_owner AS owner "
"FROM information_schema.schemata "
"WHERE schema_name = '%s'" % schema)
cursor.execute(query)
"WHERE schema_name = %(schema)s")
cursor.execute(query, {'schema': schema})
return cursor.fetchone()
def schema_exists(cursor, schema):
query = ("SELECT schema_name FROM information_schema.schemata "
"WHERE schema_name = '%s'" % schema)
cursor.execute(query)
"WHERE schema_name = %(schema)s")
cursor.execute(query, {'schema': schema})
return cursor.rowcount == 1