Skip to content

Commit 432f185

Browse files
authored
Update tabular data examples (#611)
1 parent 021dd97 commit 432f185

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/viam/app/data_client.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ async def tabular_data_by_sql(self, organization_id: str, sql_query: str) -> Lis
239239
240240
::
241241
242-
data = await data_client.tabular_data_by_sql(org_id="<your-org-id>", sql_query="<sql-query>")
242+
data = await data_client.tabular_data_by_sql(org_id="<your-org-id>", sql_query="SELECT * FROM readings LIMIT 5")
243243
244244
245245
Args:
@@ -257,13 +257,25 @@ async def tabular_data_by_mql(self, organization_id: str, mql_binary: List[bytes
257257
"""Obtain unified tabular data and metadata, queried with MQL.
258258
259259
::
260+
# using bson
261+
import bson
262+
tabular_data = await data_client.tabular_data_by_mql(org_id="<your-org-id>", mql_binary=[
263+
bson.dumps({ '$match': { 'location_id': '<location-id>' } }),
264+
bson.dumps({ "$limit": 5 })
265+
])
260266
261-
data = await data_client.tabular_data_by_mql(org_id="<your-org-id>", mql_binary=[<mql-bytes-1>, <mql-bytes-2>])
267+
# using pymongo
268+
import bson
269+
tabular_data = await data_client.tabular_data_by_mql(org_id="<your-org-id>", mql_binary=[
270+
bson.encode({ '$match': { 'location_id': '<location-id>' } }),
271+
bson.encode({ "$limit": 5 })
272+
])
262273
263274
264275
Args:
265276
organization_id (str): The ID of the organization that owns the data.
266-
mql_binary (List[bytes]):The MQL query to run as a list of BSON documents.
277+
mql_binary (List[bytes]): The MQL query to run as a list of BSON queries. You can encode your bson queries using a library like
278+
`pymongo` or `bson`.
267279
268280
Returns:
269281
List[Dict[str, ValueTypes]]: An array of data objects.

0 commit comments

Comments
 (0)