API Libraries > Python


Please refer to the full Python documentation for more details.

If you haven’t installed the Python client, refer to the installation instructions.


The Python package is called rockset and the entire API is contained within a single Python module called rockset. APIs defined in the rockset module allow you to:

  • securely connect to the Rockset service
  • create, manage and administer collections
  • issue queries against collections


If you have already configured your credentials in the command line, you can create a Client without any options and the current active credential profile will be used (please refer to the rock CLI documentation for more information):

from rockset import Client, Q, F
rs = Client()

You can also provide an API key and server when initializing the Client object as follows:

from rockset import Client, Q, F
rs = Client(api_key="<your_api_key_here>",

Alternatively, you can specify a credentials profile that was previously created in the command line:

from rockset import Client, Q, F
rs = Client(profile="prod")


The two most commonly used part of Rockset’s Python Client are:

  • Client object, Client: Used to connect securely to Rockset.
  • Query builder, Q and F: Used to build powerful and complex Rockset queries using Python expressions.

The following example is a Python program to select all documents from collection hello_world that have a field called name whose value is equal to the string "Jim Gray":

# connect to Rockset
from rockset import Client, Q, F
rs = Client()

# build a query object
q = Q('hello_world').where(F['name'] == 'Jim Gray')
results = rs.sql(q)

System-wide limits such as the biggest documents that can be added to a collection or other limits relating to field sizes can be obtained from constants that are present within the library.

  • rockset.Client.MAX_DOCUMENT_SIZE_BYTES
  • rockset.Client.MAX_FIELD_NAME_LENGTH
  • rockset.Client.MAX_FIELD_VALUE_BYTES
  • rockset.Client.MAX_ID_VALUE_LENGTH
  • rockset.Client.MAX_NAME_LENGTH
  • rockset.Client.MAX_NESTED_FIELD_DEPTH