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