Function Categories
Request Functions
Functions for accessing information about the current HTTP request:- header - Read HTTP request headers
- cookie - Read cookie values
- path - Get the current request path
- request-method - Get the HTTP method (GET, POST, etc.)
- client-ip - Get the client’s IP address
Authentication Functions
Functions for handling user authentication:- basic-auth-username - Get username from HTTP Basic Auth
- basic-auth-password - Get password from HTTP Basic Auth
- hash-password - Hash passwords using Argon2
- user-info - Get OIDC user information
File Operations
Functions for working with files and uploads:- read-file-as-text - Read file contents as text
- read-file-as-data-url - Read file as data URL
- persist-uploaded-file - Save uploaded files
- uploaded-file-path - Get path to uploaded file
Utility Functions
General-purpose utility functions:- fetch - Make HTTP requests to external APIs
- run-sql - Execute another SQL file
- set-variable - Create URLs with modified parameters
- variables - Get all request variables as JSON
- link - Build URLs with parameters
- url-encode - URL-encode strings
- random-string - Generate random strings
- hmac - Generate HMAC signatures
Usage Pattern
All SQLPage functions are called using thesqlpage. prefix:
Return Values
Functions return:- NULL when the requested value is not available or the parameter is NULL
- Errors when an operation fails (displayed to the user)
- Values of various types (TEXT, INTEGER, JSON, etc.)
Security Considerations
- Never pass user input directly to functions like
sqlpage.exec()orsqlpage.run_sql() - Always validate and sanitize user input
- Use
sqlpage.url_encode()when building URLs with user data - Store sensitive data (API keys, secrets) in environment variables, not in SQL files
- Use
sqlpage.hash_password()for password storage, never store plain text passwords
Performance Tips
- Cache results of expensive function calls using
SETvariables - Use
sqlpage.fetch(null)to conditionally skip API calls - Minimize file operations in tight loops
- Use
sqlpage.run_sql()sparingly to avoid deep nesting