Currently the API has a hard limit of 1000 rows on returned results.
This doesn’t affect computations on the clusters, just the amount of data
the API or the drivers send back on the wire.
API keys
To authenticate and use the Spatial SQL APIs and SDKs, we often require an API key. For more information, see API Keys.Python DB-API driver
To access Wherobots DB, we provide a Python DB-API implementation. The driver is a PEP-0249 compatible driver to programmatically connect to a Wherobots DB runtime and execute Spatial SQL queries.Installation
If you use Poetry in your project, add the dependency withpoetry add:
pip install it:
Usage
Usage follows the typical pattern of establishing the connection, acquiring a cursor, and executing SQL queries through it:example-wb-spatial-sql-api.py
Cursor supports the context manager protocol, so you can use it
within a with statement when needed:
close() method, as suggested by the PEP-2049
specification, to support situations where the cursor is wrapped in a
contextmanager.closing().
Runtime and region selection
You can choose the Wherobots runtime you want to use with theruntime
parameter, passing in one of the Runtime enum values.
For guidance on runtime sizing and selection, see Runtimes.
The following AWS regions are currently supported in the Wherobots Spatial SQL API:
| Wherobots Parameter | AWS Region Name | AWS Region Code | Access |
|---|---|---|---|
Region.AWS_US_WEST_2 | Oregon | us-west-2 | All Organization Editions |
Region.AWS_EU_WEST_1 | Ireland | eu-west-1 | Paid Organizations Only |
Region.AWS_US_EAST_1 | Northern Virginia | us-east-1 | Paid Organizations Only |
Region.AWS_AP_SOUTH_1 | Mumbai | ap-south-1 | Paid Organizations Only |
Version selection
When creating a session, you can set the version parameter to one of the following values:-
"latest": (Default) The most recent, stable production version. Your session will default to this if the parameter is omitted. -
"preview": The most recent pre-release Wherobots version. Use this to test new features, performance optimizations, and other upcoming changes. -
VERSION-STRING: An explicit version number to set your session to a specific Wherobots release. You can find the Wherobots versions available in your Environment Presets. Theconnect()method takes some additional parameters that can be useful for optimizing performance, controlling data formats, and managing connections:
| Parameter | Type | Description | Default |
|---|---|---|---|
results_format | ResultsFormat enum | Format for receiving query results. | arrow (Arrow encoding) |
data_compression | DataCompression enum | Compression algorithm for receiving query results. | brotli (Brotli compression) |
geometry_representation | GeometryRepresentation enum | Encoding of geometry columns returned to the client application. | ewkt (EWKT string) |
session_type | "single" or "multi" | Establishes connection type to a Wherobots runtime. | "single" (Exclusive connection) |
"multi" session type for potential cost savings, but be mindful of performance impacts from shared resources.
You might need to adjust cluster size if slowdowns occur, which could affect overall cost.
Harlequin-wherobots SQL IDE for your terminal
As an example usage for our Python DB-API driver, we also integrated with Harlequin.Quick start guide
Detailed usage guide is available as part of Harlequin’s Wherobots Adapter documentation.
JDBC (type 4) driver
We provide an open-source Java library that implements a JDBC (Type 4) driver for connecting to WherobotsDB.Installation (JDBC type 4)
To start building Java applications around the Wherobots JDBC driver, add the following line to yourbuild.gradle
file’s dependency section:
Usage (JDBC type 4)
In your application, you only need to work with Java’s JDBC APIs from thejava.sql package:
Wherobots SQL Driver TypeScript SDK
This is the TypeScript SDK for interacting with WherobotsDB. This package implements a Node.js client that programmatically connects to a WherobotsDB runtime and executes Spatial SQL queries.Prerequisites (TypeScript SDK)
The following resources are needed to run the Wherobots SQL Driver’s TypeScript SDK:- Node.js version 18 or higher
- TypeScript version 5.x (if using TypeScript)
Installation (TypeScript SDK)
To complete the installation, run the following command:Usage (TypeScript SDK)
Example: Executing SQL statement and printing results
This example:- Establishes the connection to WherobotsDB with an
asyncfunction - Calls
asyncmethods to execute SQL queries through this connection.
Code example explanation
- Calling
Connection.connect()asynchronously establishes a SQL Session connection in Wherobots Cloud and returns aConnectioninstance. - Calling the connection’s
execute()methods runs the given SQL statement and asynchronously returns the result as an Apache Arrow Table instance. - The Arrow Table instance is converted to a primitive by calling
toArray(), and then printed to the console as formatted JSON withJSON.stringify(). - Calling the connection’s
close()method tears down the SQL Session connection.
Running the example (TypeScript SDK)
- Javascript
- TypeScript
- Paste the contents of the above code example into a file called
wherobots-example.js - Run the example with:
node wherobots-example.js
Runtime and region selection (TypeScript SDK)
Select your desired Wherobots runtime using the runtime parameter and specifying a runtimeenum value.
For guidance on runtime sizing and selection, see Runtimes.
Additional parameters to connect()
The Connection.connect() function can take the following additional options:
-
sessionType:"single"or"multi"; if set to"single", then each call toConnection.connect()establishes an exclusive connection to a Wherobots runtime; if set to “multi”, then multipleConnection.connect()calls with the same arguments and credentials will connect to the same shared Wherobots runtime;"single"is the default. Consider multi-session for potential cost savings, but be mindful of performance impacts from shared resources. You might need to adjust cluster size if slowdowns occur, which could affect overall cost. -
resultsFormat: one of theResultsFormatenumvalues; Arrow encoding is the default and most efficient format for receiving query results.
Currently, only Arrow encoding is supported
dataCompression: one of theDataCompressionenumvalues; Brotli compression is the default and the most efficient compression algorithm for receiving query results.
Currently, only Brotli compression is supported
-
geometryRepresentation: one of theGeometryRepresentationenumvalues; selects the encoding of geometry columns returned to the client application. The default is EWKT (string) and the most convenient for human inspection while still being usable by geospatial data manipulation libraries. -
region: The region where the SQL session compute region. For more information, see Runtime and Region Selection.
Additional parameters to execute()
The Connection#execute method can take an optional second argument, options:
options.signal: anAbortSignalwhich can be used to cancel the execution (optional)

