Common questions (Python)¶
How to make the script support both local and cloud run
How to make the script support both local and cloud run¶
Flexible authorization
When the script runs in the cloud, it will provide a context object, which contains the server URL auto generated by the system and the API token of base. If you run the script in local, you need to manually specify these two variables; the API token can be generated in the drop-down menu "Advanced -> API Token" of the table.
Use the following method to make the script support both local and cloud run
from seatable_api import Base, context
server_url = context.server_url or 'https://cloud.seatable.io'
api_token = context.api_token or 'c3c75dca2c369848455a39f4436147639cf02b2d'
base = Base(api_token, server_url)
base.auth()
Dependencies that need to be installed to run the script local
The script need to install seatable-api
when run in local.
Additional requirements are:
- Python >= 3.5
- requests
- socketIO-client-nexus
List of libraries supported in the cloud environment
List of libraries supported in the cloud environment¶
In the cloud environment, Python scripts actually run in a Docker container environment. The container environment has some Python libraries installed by default, which can be imported in scripts. If you need to use other libraries, you need to contact us, or your script can only be run locally.
Python 3 standard library
The cloud environment now use Python 3.11, which supports importing modules in the Python standard library.
Third party libraries
The following modules are available
- SeaTable API, seatable-api
- Date/time calculation tool library, dateutils
- http request, requests
- OpenSSL library, pyOpenSSL
- Pillow library, Pillow
- Barcode library, python-barcode
- QRcode library, qrcode
- Pandas library, pandas
- Numpy library, numpy
- SMTP library, secure-smtplib
- OpenAI API library, openai
Install and use custom python libraries
Install and use custom python libraries¶
- The python libraries in SeaTable Cloud can not be changed.
- If you run your own SeaTable Server it is possible to install your own libaries.