skript-db icon

skript-db -----

Sensible SQL support in Skript



skript-db
Awesome direct database access for Skript

What makes skript-db different from other SQL addons?
  • Automatic SQL injection protection
  • Support for connections to multiple databases
  • An amazingly intuitive list variable system for reading query outputs

Syntax
Code (Text):
[the] data(base|[ ]source) [(of|at)] %string% [with [a] [max[imum]] [connection] life[ ]time of %timespan%] [[(using|with)] [a] driver %-string%]
Examples
Code (Text):
set {sql} to the database "mysql://localhost:3306/mydatabase?user=admin&password=12345&useSSL=false"
set {sql} to the database "mariadb://localhost:3306/mydatabase?user=admin&password=12345&useSSL=false"
set {sql} to the database "postgresql://localhost:3306/mydatabase?user=admin&password=12345&ssl=false"
set {sql} to the database "sqlite:database.db"

# Extra parameters:
set {sql} to the database "postgresql://localhost:3306/mydatabase?user=admin&password=12345&ssl=false" with a maximum connection lifetime of 30 minutes
set {sql} to the database "postgresql://localhost:3306/mydatabase?user=admin&password=12345&ssl=false" with a maximum connection lifetime of 30 minutes using driver "org.postgresql.Driver"
---

Effect `Execute Statement`
Executes a statement on a database and optionally stores the result in a variable. Expressions
embedded in the query will be escaped to avoid SQL injection.

If a single variable, such as `{test}`, is passed, the variable will be set to the number of
affected rows.

If a list variable, such as `{test::*}`, is passed, the query result will be mapped to the list
variable in the form `{test::<column name>::<row number>}`

If `quickly` is specified, the SQL query will be done without jumping back to main thread, which speeds it up by 50ms, however that makes code after it to also be on separate thread, you can jump back to main thread by adding `wait a tick`
Syntax
Code (Text):
[quickly] execute %string% (in|on) %datasource% [and store [[the] (output|result)[s]] (to|in) [the] [var[iable]] %-objects%]
Examples
Code (Text):
execute "select * from table" in {sql} and store the result in {output::*}
Code (Text):
execute "select * from %{table variable}%" in {sql} and store the result in {output::*}
---

Expression `Last Data Source Error` => `text`
Stores the error from the last executed statement, if there was one.
Syntax
Code (Text):
[the] [last] (sql|db|data(base|[ ]source)) error
---

Expression `Unsafe Expression` => `text`
Opts out of automatic SQL injection protection for a specific expression in a statement.
Note: If using PostgreSQL, this will always be needed, due to skript-db not supporting SQL injection protection for PostgreSQL currently.
Syntax
Code (Text):
unsafe %text%
Examples
Code (Text):
execute "select %unsafe {columns variable}% from %{table variable}%" in {sql}
Code (Text):
execute unsafe {fully dynamic query} in {sql}
Resource Information
Author:
----------
Total Downloads: 49
First Release: Mar 14, 2025
Last Update: Mar 14, 2025
Category: ---------------
All-Time Rating:
0 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings