NOTICE: All information contained herein is, and remains
the property of TechnoCore.
The intellectual and technical concepts contained
herein are proprietary to TechnoCore and dissemination of this information or reproduction of this material
is strictly forbidden unless prior written permission is obtained
from TechnoCore.
The ObjNocoDB object provides a client for interacting with a NocoDB instance using its REST API (v2). It handles the connection setup, authentication, and provides methods for common CRUD (Create, Read, Update, Delete) operations on table records.
The object is configured through the config.yaml file under the base.nocodb section. The following parameters are required:
base:
nocodb:
host: <your-nocodb-host>
port: <your-nocodb-port>
token: <your-api-token>
test_table_id: <a-table-id-for-testing>
host: The hostname or IP address of the NocoDB server.port: The port on which the NocoDB server is running (usually 8080).token: A valid API token generated from the NocoDB frontend. The header xc-token is used for authentication.test_table_id: The ID of a specific table to be used by the test_connection command for verification purposes.get_table_records(table_id, params=None): Retrieves a list of records from the specified table_id. Optional params can be passed to control pagination, filtering, etc.insert_record(table_id, data): Inserts a new record into the specified table. data should be a dictionary representing the new row.update_record(table_id, record_id, data): Updates an existing record identified by record_id in the specified table.delete_record(table_id, record_id): Deletes a record identified by record_id from the specified table.The script can be run directly from the command line to verify the connection and configuration.
test_connectionThis command attempts to fetch the first 5 records from the test_table_id specified in the configuration file. It's a simple way to confirm that the host, port, and token are all correct.
Usage:
python3 factory.core/ObjNocoDB.py
A successful run will print the fetched records (or an empty list if the table is empty) in JSON format.