:doc:`CloudTrail <../../cloudtrail>` / Client / start_query

***********
start_query
***********



.. py:method:: CloudTrail.Client.start_query(**kwargs)

  

  Starts a CloudTrail Lake query. Use the ``QueryStatement`` parameter to provide your SQL query, enclosed in single quotation marks. Use the optional ``DeliveryS3Uri`` parameter to deliver the query results to an S3 bucket.

   

  ``StartQuery`` requires you specify either the ``QueryStatement`` parameter, or a ``QueryAlias`` and any ``QueryParameters``. In the current release, the ``QueryAlias`` and ``QueryParameters`` parameters are used only for the queries that populate the CloudTrail Lake dashboards.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/cloudtrail-2013-11-01/StartQuery>`_  


  **Request Syntax**
  ::

    response = client.start_query(
        QueryStatement='string',
        DeliveryS3Uri='string',
        QueryAlias='string',
        QueryParameters=[
            'string',
        ],
        EventDataStoreOwnerAccountId='string'
    )
    
  :type QueryStatement: string
  :param QueryStatement: 

    The SQL code of your query.

    

  
  :type DeliveryS3Uri: string
  :param DeliveryS3Uri: 

    The URI for the S3 bucket where CloudTrail delivers the query results.

    

  
  :type QueryAlias: string
  :param QueryAlias: 

    The alias that identifies a query template.

    

  
  :type QueryParameters: list
  :param QueryParameters: 

    The query parameters for the specified ``QueryAlias``.

    

  
    - *(string) --* 

    

  :type EventDataStoreOwnerAccountId: string
  :param EventDataStoreOwnerAccountId: 

    The account ID of the event data store owner.

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'QueryId': 'string',
          'EventDataStoreOwnerAccountId': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **QueryId** *(string) --* 

        The ID of the started query.

        
      

      - **EventDataStoreOwnerAccountId** *(string) --* 

        The account ID of the event data store owner.

        
  
  **Exceptions**
  
  *   :py:class:`CloudTrail.Client.exceptions.EventDataStoreARNInvalidException`

  
  *   :py:class:`CloudTrail.Client.exceptions.EventDataStoreNotFoundException`

  
  *   :py:class:`CloudTrail.Client.exceptions.InactiveEventDataStoreException`

  
  *   :py:class:`CloudTrail.Client.exceptions.InvalidParameterException`

  
  *   :py:class:`CloudTrail.Client.exceptions.InvalidQueryStatementException`

  
  *   :py:class:`CloudTrail.Client.exceptions.MaxConcurrentQueriesException`

  
  *   :py:class:`CloudTrail.Client.exceptions.InsufficientEncryptionPolicyException`

  
  *   :py:class:`CloudTrail.Client.exceptions.InvalidS3PrefixException`

  
  *   :py:class:`CloudTrail.Client.exceptions.InvalidS3BucketNameException`

  
  *   :py:class:`CloudTrail.Client.exceptions.InsufficientS3BucketPolicyException`

  
  *   :py:class:`CloudTrail.Client.exceptions.S3BucketDoesNotExistException`

  
  *   :py:class:`CloudTrail.Client.exceptions.OperationNotPermittedException`

  
  *   :py:class:`CloudTrail.Client.exceptions.UnsupportedOperationException`

  
  *   :py:class:`CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException`

  