Operations are callable units of work. Operations can be written in Python, SQL, and JavaScript and they may be private or called by other operations within the application. Here's a quick look at basic usage examples for Python and SQL.
Python in Transposit is helpful when you need to encode business logic, make API requests, run queries, or quickly transform the data resulting from one of your queries.
A basic example of a Python operation:
def run(params):
api.log("Hello World")
return {
"mission": "complete"
}
To run another operation from inside a Python operation, use the run
method. The first argument is the operation reference; the second argument is a map of operation parameters to run with:
api.run("this.operation_name", {"parameter_name": parameter_value})
To run a SQL statement inside a Python operation, use the query
method:
api.query("select * from connection.operation")
To print to the console, use api.log
:
api.log("hello world")
Learn more in the Python operations reference.
SQL is designed to easily join, filter, and organize your data in the way you need it. It abstracts away the details of data representation and allows you, the developer, to express your intent, while the relational engine translates that intent, optimizes it, and executes it. In this way, SQL offers a simpler way of stating this intent than you would ever get writing your own custom code.
A primary use of SQL operations is querying data. Here's an example of a basic SELECT
statement:
SELECT * FROM database.get_users WHERE lastName='smith' LIMIT 50
Data can be joined, as you'd expect in SQL:
SELECT * FROM database.get_users
AS A JOIN database.get_user AS B ON A.id = B.id
WHERE A.lastName='smith' LIMIT 50
Creating SQL operations from a template (choose SQL from template in the menu) starts you off with scaffolded code based on the syntax and parameters of a given data connection operation.
Learn more in the SQL operations reference.
Transposit enforces usage limits. This helps to protect our infrastructure as well as your API rate limits.
A request may consist of many operations. A request starts when a developer runs an operation in the console, a scheduled task is started or an endpoint is accessed.
Currently Transposit does not support multiple users modifying an application in the console simultaneously. Doing so will cause unexpected behavior and lost code.
If you need to have more than one user modify an application in the console, coordinate to make sure that each person accesses the console in a sequential fashion.
runBulk
), you'll use CPU time more quickly than execution time; if you use timing events like setTimeout
, you'll likely use CPU time less quickly than execution time.To make sure you don't accidentally run through your API rate limits for your data connections, Transposit limits the number of API calls.