Skip to main content
SQLPage provides a rich set of built-in functions that you can call directly from your SQL queries. These functions allow you to interact with HTTP requests, handle authentication, manipulate files, and perform various utility operations.

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:

File Operations

Functions for working with files and uploads:

Utility Functions

General-purpose utility functions:

Usage Pattern

All SQLPage functions are called using the sqlpage. prefix:
SELECT 'text' as component,
    sqlpage.cookie('username') as contents;

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() or sqlpage.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 SET variables
  • Use sqlpage.fetch(null) to conditionally skip API calls
  • Minimize file operations in tight loops
  • Use sqlpage.run_sql() sparingly to avoid deep nesting

Next Steps

Explore individual function documentation to see detailed parameters, examples, and use cases for each function.

Build docs developers (and LLMs) love