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:
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>", api_server="api.rs2.usw2.rockset.com")
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: Used to connect securely to Rockset.
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
# 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.