Metadata-Version: 1.2
Name: pyzure
Version: 0.0.2
Summary: Easily send data to Microsoft Azure SQL DB
Home-page: https://github.com/dacker-team/pyzure
Author: Dacker
Author-email: hello@dacker.co
License: MIT License

Copyright (c) 2018 dacker-team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Description: pyred
        =====
        
        A python package to easily send data to Microsoft Azure SQL DB
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
        1) Installation
        '''''''''''''''
        
        Open a terminal and install pyzure package
                                                           
        ::
        
            pip install pyzure
        
        
        2) Use
        ''''''
        
        1) Be sure that you have set environment variables with Azure credentials like this:
        
        
        ::
        
            export AZURE_{INSTANCE}_DATABASE=""
            export AZURE_{INSTANCE}_USERNAME=""
            export AZURE_{INSTANCE}_HOST=""
            export AZURE_{INSTANCE}_PORT=""
            export AZURE_{INSTANCE}_PASSWORD=""
        
        2) Be also sure that your IP address is authorized for the azure cluster/instance.
        
        3) Prepare your data like that:
        
        
        .. code:: python
        
            data = {
                    "table_name"    : 'name_of_the_azure_schema' + '.' + 'name_of_the_azure_table'
                    "columns_name"  : [first_column_name,second_column_name,...,last_column_name],
                    "rows"      : [[first_raw_value,second_raw_value,...,last_raw_value],...]
                }
        
        4) Send your data (use the same {INSTANCE} parameter as environment variables):
        
        
        .. code:: python
        
            import pyzure
            pyzure.send_to_azure(instance, data, replace=True, batch_size=1000, types=None, primary_key=(), create_boolean=False)
        
        -  replace (default=True) argument allows you to replace or append data
           in the table
        -  batch\_size (default=1000) argument also exists to send data in
           batchs
        - types, primary_key and create_boolean are explained below
        
        3) First Example
        ''''''''''''''''
        
        You have a table called dog in you animal scheme. This table has two columns : 'name' and 'size'.
        You want to add two dogs (= two rows) : Pif which is big and Milou which is small.
        *data* will be like that:
        
        .. code:: python
        
            import pyzure
            data = {
                    "table_name"    : 'animal.dog'
                    "columns_name"  : ['name','size'],
                    "rows"      : [['Pif','big'], ['Milou','small']]
                }
            pyzure.send_to_azure({INSTANCE},data)
        
        4) Function *create_table*
        ''''''''''''''''''''''''''
        pyzure has a *create_table* function with this signature:
        
        .. code:: python
        
            import pyzure
            pyzure.create_table({INSTANCE}, data, primary_key=(), types=None)
        
        This function is automatically called in the *send_to_azure* function if the table is not created. You can also call it with the "create_boolean" parameter of the *send_to_reshift* function or by setting "primary_key" or "types" parameters.
        
        -  primary_key : if you have 3 columns (ie: columns_name=[a,b,c]) and you want to set b as primary key, set primary_key=(b)
        -  types: *create_table* function guesses types of each column. But you can set a "types" argument. It is a dictionary like {'b': 'VARCHAR(12)'} or  {'b': 'INTEGER NOT NULL'} to set types of b column.
        
Keywords: send data microsoft azure sql db easy
Platform: UNKNOWN
Requires-Python: >=3
