Hoverfly Cloud
Visit Our Main SitePricingTry Hoverfly Cloud
  • Introduction
  • Use cases for API Simulation
  • Key concepts
  • What's New
  • Dashboard
  • Simulation
    • Create simulations
    • Configuring Request Matchers
      • JSON Request Matchers on the Body
        • EXACT Matcher
        • JSON Matcher
        • JSON Partial Matcher
        • JSONPath Matcher
        • Regular Expression Matcher
      • Handling the response when Hoverfly cannot match
    • Building a JSON Response
      • Using a JSON object from the Request
      • Looping over a JSON array from the Request
    • Simulating Webhooks and Callbacks
    • Using templating in simulations
      • Render back any part of the Request
      • Render synthetic data
      • Faker functions
      • Render dates and times with offsets
      • Conditional logic
      • Looping over arrays
      • Variables and Arrays
      • Arithmetic operations
      • String operations
      • Validation operations
      • Simulating a persistent backend
      • Transitioning state between requests
      • Combining and nesting templating functions
      • Useful helper functions
      • Avoiding HTML encoding in function return values
    • Using data sources in simulations
      • Querying data sources
      • Updating data in data sources
      • Deleting data from data sources
      • Inserting data into a data source
      • Guidance on using the SQL like syntax
    • Working with Simulation Files
  • Service
    • Start a new service
    • Use a service
    • Update a service
    • Configuring Journal Indexing
  • Command line interface
    • Hoverfly Cloud CLI commands
  • Tutorials
    • Quickstart
    • Creating simulations and services
      • Tutorial 1: Create a service and simulation manually
      • Tutorial 2: Create a service and simulation by importing from a Swagger specification
      • Tutorial 3: Create a service and simulation by capturing real API traffic
    • Response Templating
      • Tutorial 4: Response Templating
    • Hoverfly service modes
      • Tutorial 5: Simulate, Capture, Spy and Passthrough modes
    • Automating with the CLI and API
      • Tutorial 6: Using the CLI and the Hoverfly Cloud API
Powered by GitBook
On this page
  • Supported SQL syntax
  • SQL Commands
  • Conditions
  • Other considerations
  • Examples
  1. Simulation
  2. Using data sources in simulations

Guidance on using the SQL like syntax

With Hoverfly Cloud Enterprise you can use SQL-like syntax for querying, updating and deleting from in-memory csv data sources.

PreviousInserting data into a data sourceNextWorking with Simulation Files

Last updated 3 months ago

Supported SQL syntax

You can use a simplified SQL like syntax to select, update and delete rows.

SQL Commands

  • INSERT is not supported. To add data you must use the template function.

  • SELECT [column-names] FROM [data-source-name] WHERE [conditions] (* can be used to indicate all colmuns)

  • UPDATE [data-source-name] SET [[column-name] = ‘[value]’,] WHERE [conditions]

  • DELETE FROM [data-source-name] WHERE [conditions]

Conditions

  • Only simple conditions are supported.

  • You can chain conditions using AND. OR is not supported.

  • The following comparison operators are supported in conditions:

= equals

> greater than

< less than

>= greater than or equal to

<= less than or equal to

!= not equal to

Other considerations

  • Capitalization of SQL keywords is required.

  • Spaces between components of the SQL statement are required.

  • Every value provided to a condition whether a number or a string must be enclosed in quotes.

  • Data source names must not be in quotes.

  • Joins across different data sources are not supported..

Examples

For illustration we will use this data source called "pets":

id
category
name
status

1000

birds

Archie

available

1001

dogs

Zipper

available

1002

dogs

Teddy

sold

SELECT * FROM pets WHERE category = 'dogs' AND id >= '1002'

SELECT name, status FROM pets WHERE category = 'birds'

UPDATE pets SET status = 'sold' WHERE name = 'Archie'

UPDATE pets SET status = 'sold', name = 'Name expunged' WHERE id > '10'

DELETE FROM pets WHERE category = 'dogs' AND id > '1001'
csvAddRow