Fill in the new function again! Starting with version 1.8.0, the SeaTable Developer edition has added the ability to run Python (see the manual for details), making it easier to quickly develop custom data processing flows, making building small applications easier and more imaginative.

SeaTable is a new collaborative table and low-code platform that supports rich data types such as images, files, and long text. Its API provides CRUD operations on records, that is, creating, reading, updating, deleting, and so on. In this way, we can use it as a lightweight database.

For example, while saving, presenting, and sharing data can be a hassle when writing small applications in Python scripts, using SeaTable, a collaborative tabular and low-code platform, can greatly simplify the development of small applications. It provides a running environment for Python scripts, so that scripts and data can be managed in one place instead of having to find a separate server.

The convenience it provides for us can be summarized as follows:

  • You can store multiple script files in a table and execute them with one click.
  • You can schedule scripts to run daily without having to write a cron task yourself.
  • We can add buttons to the table to invoke scripts, making our table more like an application.

Here’s a closer look.

Click the script to run:

Add a button to the table to invoke the script:

The implementation of the Python script runner

How is the script executed in SeaTable? Let’s take a look.

architecture

The Python script running of SeaTable includes three parts: SeaTable, SeaTable FAAS Scheduler, and Python Runner. Their functions and relationships are as follows:

  • SeaTable: Creates, saves, modifies scripts, and sends running requests.
  • SeaTable FAAS Scheduler: a Scheduler that schedules script requests, saves scheduled tasks, and collects statistics on script running results. Equivalent to a master node.
  • Python Runner: Actually runs the script, which is equivalent to a worker node. Python Runner receives a request to run a script, downloads the script content and launches a Docker container to run the script. After the script is executed, the container is automatically destroyed to ensure security.

Python Runner and SeaTable FAAS Scheduler can be deployed to the same machine, with the following structure:

If you need to run a lot of Python scripts, you can deploy several More Python Runners by placing a Load Balance component in front of them.

Context context

One of the features of SeaTable scripts is the context in which the user is currently focusing on which row of which table. So we can do something on this row. Let’s look at a simple example: when a user clicks a button, the current line of content is sent to the enterprise wechat group. As follows:

From seatable_API import context # This script shows the webhook address automatically generated by using the enterprise wechat group robot to send a row of data in the table to the enterprise wechat group. WEBHOOK_URL = "XXXXX"; Use context to retrieve the contents of the current line. Current_row = context. Current_row MSG = format_msg(" receive a charge ", current_ROW) requests. Post (url=WEBHOOK_URL, msg, headers={ "Content-Type": "application/json" } )Copy the code

conclusion

With the addition of the ability to run Python, SeaTable Developer edition’s Python API has been refined to make it easier to quickly develop custom data processing processes, which is a real miracle for us as developers. It can be downloaded for free, deployed privately, and has no limits on the number of lines, storage, or API calls. It also has a nice, easy-to-use table interface that allows multiple people to collaborate in real time. It also has powerful forms and data collection table capabilities. It is well suited as the data collaboration center within the enterprise to achieve centralized management, visualization and automation of data.