From EventScripts Community Encyclopedia
EventScripts 1.5 introduced the capability to create local SQLite database files for querying from your server.
For advanced scripters, EventScripts 1.5+ has basic built-in support for SQLite database files. These databases support a full range of SQL syntax as it's a full implementation of the SQLite database engine. File paths are similar to that of keygroup databases. Note-- these commands are not multi-threaded and es_sql does not allow remote database support. See the ServerMail example provided with EventScripts for an advanced example of usage.
The database files used by EventScripts are always stored in the es_db-name.sqldb filename syntax. This is done for security reasons to prevent overwriting other files.
- es_sql open <db-name> [dbdir]
- Must be called before using any other es_sql command. Opens and/or creates a database file by the name of es_db-name.sqldb in the directory mentioned (supports same syntax as keygroup databases, e.g. "|servermail"). The db-name should be referenced in all future es_sql statements.
- es_sql close <db-name>
- Closes and flushes the database data to disk. In order to use the database again, you need to es_sql open it.
- es_sql query <db-name> [result-keygroup] "<SQL-string>"
- Performs the SQL-string database query on the named database. Optionally, the name of a keygroup can be specified that will include the data returned from the query (if any). Queries can use any of the SQLite syntax.
- es_sql queryvalue <db-name> <result-variable> "<SQL-string>"
- Performs the SQL-string database query on the named database. EventScripts looks at the first row, first column and stores the value inside the server variable specified. This is useful if you just need to return a one-shot COUNT or SUM value in your query and you don't want to loop through a keygroup.
- es_formatqv <output-var> "<format-string>" [variablename1] [variablename2] ... [variablename9]
- Just like es_formatv only it will escape the inserted strings to ensure that you have a safe SQL string. This command is highly recommended to be used with es_sql query* commands.