REPL
The REPL (Read-Eval-Print Loop) is a powerful interface that allows ROOT users to interact directly with the underlying database system in Kinesis API. This advanced feature provides a command-line style interface for executing database operations, testing queries, and managing data structures without leaving the web interface.
Access Control
⚠️ Important: The REPL interface is only accessible to users with the ROOT role. This restriction is in place because the REPL provides direct access to the database, bypassing the standard API permissions and validations.
Accessing the REPL
To access the REPL interface:
- Log in with a ROOT user account
- Navigate to
/web/repl
in your browser or select "REPL" from the navigation menu
REPL Interface
The REPL interface consists of:
- Command Input Area: A textarea where you can enter database commands
- Output Format Selector: Choose between Table, JSON, and Standard output formats
- Execute Button: Run the entered command
- Output Display: Shows the results of executed commands
Available Commands
The REPL supports a comprehensive set of commands for interacting with the database:
Table Management
Command | Description | Example |
---|---|---|
CREATE_TABLE | Create a new table with optional schema | CREATE_TABLE users name STRING --required age INTEGER |
DROP_TABLE | Delete a table | DROP_TABLE users |
GET_TABLE | Show table schema | GET_TABLE users |
GET_TABLES | List all tables | GET_TABLES |
UPDATE_SCHEMA | Update table schema | UPDATE_SCHEMA users --version=2 active BOOLEAN |
Record Management
Command | Description | Example |
---|---|---|
INSERT | Insert a new record | INSERT INTO users ID 1 SET name = "John" age = 30 |
UPDATE | Update an existing record | UPDATE users ID 1 SET age = 31 |
DELETE | Delete a record | DELETE FROM users 1 |
GET_RECORD | Retrieve a single record | GET_RECORD FROM users 1 |
GET_RECORDS | Retrieve all records from a table | GET_RECORDS FROM users |
SEARCH_RECORDS | Search for records | SEARCH_RECORDS FROM users MATCH "John" |
Help
Command | Description | Example |
---|---|---|
HELP | Show general help | HELP |
HELP [command] | Show help for a specific command | HELP CREATE_TABLE |
Output Formats
The REPL supports three output formats:
- Table: Formats results as ASCII tables for easy reading
- JSON: Returns results in JSON format for programmatic analysis
- Standard: Simple text output with minimal formatting
Using the REPL
Basic Usage
- Enter a command in the input area
- Select your preferred output format
- Click "Execute" to run the command
- View the results in the output display
Schema Definition
When creating or updating tables, you can define schema fields with various constraints:
CREATE_TABLE users
name STRING --required --min=2 --max=50
email STRING --required --unique --pattern="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
age INTEGER --min=0 --max=120
Available field types:
- STRING: Text data
- INTEGER: Whole numbers
- FLOAT: Decimal numbers
- BOOLEAN: True/false values
Available field constraints:
--required
: Field must have a value--unique
: Field values must be unique within the table--min=<value>
: Minimum value (for numbers) or length (for strings)--max=<value>
: Maximum value (for numbers) or length (for strings)--pattern=<regex>
: Regular expression pattern for string validation--default=<value>
: Default value if none is provided
Security Considerations
The REPL provides direct access to the database, which comes with significant power and responsibility:
- Limited Access: Only ROOT users can access the REPL
- Audit Trail: All REPL commands are logged in the system events
- No Undo: Most operations cannot be undone, especially schema changes and deletions
- Performance Impact: Complex queries on large tables may impact system performance
Best Practices
- Test in Development: Use the REPL in development environments before running commands in production
- Back Up First: Create backups before making significant schema changes
- Use Transactions: For complex operations, consider using transactions to ensure data integrity
- Document Changes: Keep records of schema changes made through the REPL
- Prefer API: For routine operations, use the standard API endpoints rather than direct REPL access
Example Use Cases
The REPL is particularly useful for:
- Prototyping: Quickly create and test database structures
- Data Cleanup: Fix or remove problematic records
- Schema Evolution: Add or modify fields in existing tables
- Troubleshooting: Inspect database contents for debugging
- Data Migration: Bulk operations during system updates
Related Documentation
- Kinesis DB - Learn about the underlying database system