# Postgresql\_exec module

**URL:** <https://forum.ansible.com/t/postgresql-exec-module/24137>\
**Category:** Ansible Developer\
**Created:** [April 4, 2017, 10:20am UTC](https://forum.ansible.com/t/postgresql-exec-module/24137 "2017-04-04T10:20:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giles\_Westwood](https://avatars.discourse-cdn.com/v4/letter/g/3ab097/32.png) [@Giles\_Westwood](https://forum.ansible.com/u/Giles_Westwood)\
**Post date:** [April 4, 2017, 10:20am UTC](https://forum.ansible.com/t/postgresql-exec-module/24137/1 "2017-04-04T10:20:28Z")

</div>

Hi Ansible devs,

I’m attempting to make this module 2.x compatible in the hope I can get it added to core because it would nicely add to the postgresql\_ set of modules

[https://github.com/jirutka/ansible-modules/blob/master/action\_plugins/postgresql\_exec.py](https://github.com/jirutka/ansible-modules/blob/master/action_plugins/postgresql_exec.py)

[https://github.com/jirutka/ansible-modules/blob/master/library/database/postgresql\_exec.py](https://github.com/jirutka/ansible-modules/blob/master/library/database/postgresql_exec.py)

It’s a action\_plugin pair that templates / selects a file then hands of the pycog work to a module.

As and example of a 2.x module that does the same I’m looking to:-

lib/ansible/plugins/action/template.py

So I’m going to have a try at adjusting it to use the 2.x api today.

My other option is to take one of the postgresql\_ modules and may be just create a postgresql\_psql version that can execute sql passed as a parameter to learn how they work, then try and add the action module templating afterwards.

Any advice / help appreciated.

---

<div class="post-metadata">

**Author:** ![Giles\_Westwood](https://avatars.discourse-cdn.com/v4/letter/g/3ab097/32.png) [@Giles\_Westwood](https://forum.ansible.com/u/Giles_Westwood)\
**Post date:** [April 4, 2017, 4:15pm UTC](https://forum.ansible.com/t/postgresql-exec-module/24137/2 "2017-04-04T16:15:38Z")

</div>

I’ve managed to get the key features working so I’m just going to clean it all up and then start work on the module itself to bring that inline with the other Postgres modules.

[https://github.com/gilesw/ansible-modules/](https://github.com/gilesw/ansible-modules/)

---

<div class="post-metadata">

**Author:** ![Giles\_Westwood](https://avatars.discourse-cdn.com/v4/letter/g/3ab097/32.png) [@Giles\_Westwood](https://forum.ansible.com/u/Giles_Westwood)\
**Post date:** [April 6, 2017, 12:08pm UTC](https://forum.ansible.com/t/postgresql-exec-module/24137/3 "2017-04-06T12:08:54Z")

</div>

Okay mostly done now with tests running in travis ci. I’ve moved it all to a new repo as the original author doesn’t want to be involved:-

[https://github.com/gilesw/ansible-postgresql\_exec](https://github.com/gilesw/ansible-postgresql_exec)

Key test I need to make is character encoding and escaping as I’ve removed some of the code from his original code.
