Python
    • Dark
      Light

    Python

    • Dark
      Light

    Article summary

    Description

    We use a wrapper for PyHive which uses simplified functions.

    Installation

    PyPi

    $ pip install doorda-sdk

    Source

    Download from: https://github.com/Doorda/doorda-python-sdk/releases

    wget https://github.com/Doorda/doorda-python-sdk/archive/1.0.10.zip
    
    unzip 1.0.10.zip

    Install

    python setup.py install

    Connect to database

    from doorda_sdk.host import client
    
    conn = client.connect(username="username",
    password="password",
    catalog="catalog_name",
    schema="schema_name")
    cursor = conn.cursor()

      Execute Queries

    # SQL Statements do not need semi-colon at the end
    cursor.execute("SELECT * FROM table_name")
    
    # Returns generator of results
    # Does not put result into memory. Iterates through rows in a streaming fashion.
    for row in cursor.iter_result():
        # Do something with row
    
    # Fetch all results
    rows = cursor.fetchall()
    
    # Fetch one results
    rows = cursor.fetchone()
    
    # Fetch multiple results
    rows = cursor.fetchmany(size=10)
    
    # Get list of column names
    cursor.col_names
    
    # Get column names mapped to data types
    cursor.col_types

      Simplified Functions

    # Check database connection
    results = cursor.is_connected()
    
    # List all catalogs
    rows = cursor.show_catalogs()
    
    # List all tables in Schema
    rows = cursor.show_tables("catalog_name", "schema_name")
    
    # Get number of rows
    rows = cursor.table_stats(catalog="catalog_name", 
                              schema="schema_name",
                              table="table_name")



    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.
    ESC

    Eddy AI, facilitating knowledge discovery through conversational intelligence