Welcome to the Hangar Open Beta. Please report any issue you encounter on GitHub!
Avatar for 4w3

Sensible SQL support in Skript

Report skript-db?

skript-db

Awesome direct database access for Skript

This is a fork of Govinda's fork of btk5h's skript-db, modified to function with Minecraft versions 1.20 and above, including bug fixes and performance improvements

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
[the] data(base|[ ]source) [(of|at)] %string% [with [a] [max[imum]] [connection] life[ ]time of %timespan%] [[(using|with)] [a] driver %-string%]
Examples
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
[quickly] execute %string% (in|on) %datasource% [and store [[the] (output|result)[s]] (to|in) [the] [var[iable]] %-objects%]
Examples
execute "select * from table" in {sql} and store the result in {output::*}
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
[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
unsafe %text%
Examples
execute "select %unsafe {columns variable}% from %{table variable}%" in {sql}
execute unsafe {fully dynamic query} in {sql}

Information

CategoryAdmin Tools
Published onMarch 14, 2025
LicenseMIT
Downloads11
Stars0
Watchers0
Library
Addon

Pinned Versions

Members

Avatar for 4w3

4w3

Owner