# Create module ansible

**URL:** <https://forum.ansible.com/t/create-module-ansible/32081>\
**Category:** Ansible Project\
**Created:** [January 29, 2020, 11:06am UTC](https://forum.ansible.com/t/create-module-ansible/32081 "2020-01-29T11:06:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [January 29, 2020, 11:06am UTC](https://forum.ansible.com/t/create-module-ansible/32081/1 "2020-01-29T11:06:07Z")

</div>

Hello guy !! 🙂

I want create module for connection and execution script sql in my database MSSQL.  
I have create programme python :

**#!/usr/bin/python**

**import pymssql**

**conn = pymssql.connect(host=“my\_host\_database”, user=“my\_user”, password=“my\_password”, database=“my\_database”)**  
**cur = conn.cursor()**

**try:**  
**with open(‘script\_sql.sql’) as f:**  
**cur.execute(f.read().decode(‘utf-8’))**  
**conn.commit()**  
**except:**

**print(“Il y a une erreur lors de l’execution du script”)**

**cur.close()**

This programe works perfectly, but i want create module ansible for this programme python.

For exemple, my goal is that my module name **mssql\_query** :

- name: “Execute my new module”  
mssql\_query:  
name: **my\_host\_database**  
user: **my\_user**  
password: **my\_password**  
database: **my\_database**  
file\_sql: **./script\_sql.sql**

Someone can you help me for transform my program python in module ansible please ?

Thanks you very much !! 🙂

Best regards,

Karther
