Es sql query

From EventScripts Community Encyclopedia


Overview

Syntax: es_sql query <db-name> [result-keygroup] "<SQL-statement>"

Note: Command parameters are described inside the < and > characters. Optional parameters are contained within [ and ] characters.

Variation of this command that doesn't expand variables: es_xsql query

Description

Executes a SQL statement against a SQLite database and returns the results, optionally, in a keygroup.

Parameters

  • db-name - The name of the database to query. The database must have been opened first by a call to es_sql open
  • [result-keygroup] - A keygroup can be created to store the results of the SQL statement.
  • "SQL-statement - A SQL statement that conforms to the Structured Query Language (SQL) syntax supported by SQLite3. Must be in quotation marks, with strings in single quotes,


Examples

See the ServerMail example in ES v1.5 for a detailed example.

// open a SQLite database file, creates/opens es_mydb.sqldb
es_sql open mydb |myscript
es_sql query mydb mykeygroup "SELECT * FROM mytable WHERE myname='Mattie';"
es_foreachkey mykey in mykeygroup "es_msg Found a result!"
// ...
// quick query where we don't care about the return
es_sql query mydb "INSERT INTO mytable (myname, mymoney) VALUES ('Venjax', 9999);"


Notes

  • Must call es_sql open on the database before trying queries.
  • This is a synchronous call.
  • SQLite has very good performance, but it will be dependent on just how large the table is.
  • For complicated queries or large tables, it's recommended that you wait to perform the query until a more acceptable time.
  • Requires EventScripts v1.5.


See also

blog comments powered by Disqus