Anons79 Mini Shell

Directory : /proc/self/root/lib/python2.7/site-packages/ansible/modules/database/mssql/
Upload File :
Current File : //proc/self/root/lib/python2.7/site-packages/ansible/modules/database/mssql/mssql_db.pyo

�
�Udac@`s	ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZdZ
yddlZWn#ek
r�ej�Z
eZnXeZddlmZmZd
�Zd�Zd�Zd�Zd�Zedkre�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: mssql_db
short_description: Add or remove MSSQL databases from a remote host.
description:
   - Add or remove MSSQL databases from a remote host.
version_added: "2.2"
options:
  name:
    description:
      - name of the database to add or remove
    required: true
    aliases: [ db ]
  login_user:
    description:
      - The username used to authenticate with
  login_password:
    description:
      - The password used to authenticate with
  login_host:
    description:
      - Host running the database
  login_port:
    description:
      - Port of the MSSQL server. Requires login_host be defined as other than localhost if login_port is used
    default: 1433
  state:
    description:
      - The database state
    default: present
    choices: [ "present", "absent", "import" ]
  target:
    description:
      - Location, on the remote host, of the dump file to read from or write to. Uncompressed SQL
        files (C(.sql)) files are supported.
  autocommit:
    description:
      - Automatically commit the change only if the import succeed. Sometimes it is necessary to use autocommit=true, since some content can't be changed
        within a transaction.
    type: bool
    default: 'no'
notes:
   - Requires the pymssql Python package on the remote host. For Ubuntu, this
     is as easy as pip install pymssql (See M(pip).)
requirements:
   - python >= 2.7
   - pymssql
author: Vedit Firat Arig (@vedit)
s
# Create a new database with name 'jackdata'
- mssql_db:
    name: jackdata
    state: present

# Copy database dump file to remote host and restore it to database 'my_db'
- copy:
    src: dump.sql
    dest: /tmp

- mssql_db:
    name: my_db
    state: import
    target: /tmp/dump.sql
s
#
N(t
AnsibleModuletmissing_required_libcC`s'|jd|�|j�t|j�S(Ns5SELECT name FROM master.sys.databases WHERE name = %s(texecutetcommittbooltrowcount(tconntcursortdb((sK/usr/lib/python2.7/site-packages/ansible/modules/database/mssql/mssql_db.pyt	db_existsgs
cC`s!|jd|�t|||�S(NsCREATE DATABASE [%s](R
R(RRR((sK/usr/lib/python2.7/site-packages/ansible/modules/database/mssql/mssql_db.pyt	db_createmscC`sKy|jd|�Wntk
r(nX|jd|�t|||�S(Ns;ALTER DATABASE [%s] SET single_user WITH ROLLBACK IMMEDIATEsDROP DATABASE [%s](R
t	ExceptionR(RRR((sK/usr/lib/python2.7/site-packages/ansible/modules/database/mssql/mssql_db.pyt	db_deleters
cC`s�tjj|�r�t|d�}zyd|}xQ|D]I}|dkrKPq5|jd�rt|j|�d|}q5||7}q5W|j|�|j�Wd|j�Xd	Sd
SdS(Ntrs	USE [%s]
tGOisimport successfultiscannot find target file(isimport successfulR(iscannot find target filescannot find target file(	tostpathtisfiletopentNonet
startswithR
Rtclose(RRtmoduleRttargettbackuptsqlQuerytline((sK/usr/lib/python2.7/site-packages/ansible/modules/database/mssql/mssql_db.pyt	db_import{s 




cC`sMtdtdtdtddg�dtdd�d	tddd
t�dtdt�dtdd
�dtdd�dtdddt�dtddddddg���}ts�|jdtd�dt�n|j	d}|j	d}|j	d}|j	d}|j	d}|j	d	}|j	d}|j	d}|}	|d
kr`d||f}	n|dkr�|dkr�|jdd�ny4t
jd|d|d|	dd �}
|
j�}Wnat
k
r"}d!t|�kr|j\}
}|jdd"|
|f�q#|jdd#�nX|
jt�t}t|
||�r|dkr�yt|
||�}Wqt
k
r�}|jdd$t|��qXq3|dkr3|
j|�t|
||||�\}}}|d%kr�|jdd&|�q|jd'td|d|�q3n|dkrqyt|
||�}Wq3t
k
rm}|jdd(t|��q3Xn�|dkr3yt|
||�}Wn-t
k
r�}|jdd(t|��nX|
j|�t|
||||�\}}}|d%kr|jdd&|�q3|jd'td|d|�n|jd'|d|�dS()Nt
argument_spectnametrequiredtaliasesRt
login_usertdefaultRtlogin_passwordtno_logt
login_hostt
login_portt1433R t
autocommitttypeRtstatetpresenttchoicestabsenttimporttmsgtpymssqlt	exceptions%s:%ssCwhen supplying login_user arguments login_password must be providedtusertpasswordthosttdatabasetmastersUnknown databasesERROR: %s %ss�unable to connect, check login_user and login_password are correct, or alternatively check your @sysconfdir@/freetds.conf / ${HOME}/.freetds.confserror deleting database: is%stchangedserror creating database: (RtdicttTrueRtFalsetmssql_foundt	fail_jsonR	tPYMSSQL_IMP_ERRtparamsR8tconnectRRtstrtargsR0RRR$t	exit_jsonR(RRR2R0R R)R+R-R.tlogin_querystringRRteterrnoterrstrR?trctstdouttstderr((sK/usr/lib/python2.7/site-packages/ansible/modules/database/mssql/mssql_db.pytmain�s�







$
!
!"!
!t__main__(t
__future__RRRR1t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRt	tracebackRRER8tImportErrort
format_excRBRCRAtansible.module_utils.basicRR	RRRR$RRt__name__(((sK/usr/lib/python2.7/site-packages/ansible/modules/database/mssql/mssql_db.pyt<module>s0


3

						V

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]