Skip to content

Database

Joe91 edited this page Nov 1, 2026 · 3 revisions

If you contribute to fun-bots please don't use the SQL library of Venice Unleashed directly. We provide our own class named Database (ext/Server/Database.lua, server side only); it writes to the mod.db of the mod.

local m_Database = require('Database')

Field types: DatabaseField.ID, Text, PrimaryText (unique text), Integer, Float, Boolean, Time, NULL.

💥 Create a Database-Table

m_Database:CreateTable('TestName', {
	DatabaseField.ID,
	DatabaseField.Text,
	DatabaseField.Integer,
	DatabaseField.Time
}, {
	'ID',
	'Key',
	'Value',
	'Time'
})

➕ Insert an Entry to the Database-Table

local s_LastId = m_Database:Insert('TestName', {
	ID = DatabaseField.NULL,
	Key = 'Hello',
	Value = 'World',
	Time = m_Database:Now()
})

✏️ Update an Entry

The third argument names the field to match; its value is taken from the parameters.

m_Database:Update('TestName', {
	Key = 'Hello',
	Value = 'Universe'
}, 'Key')

✖️ Delete an Entry on the Database-Table

m_Database:Delete('TestName', {
	ID = 0
})

📄 Fetch a single Record from the Database-Table

local s_Single = m_Database:Single('SELECT * FROM `TestName` WHERE `Key`=' .. m_Database:Quote('Hello'))

📖 Fetch all Records from the Database-Table

local s_All = m_Database:Fetch('SELECT * FROM `TestName` WHERE `Key`=' .. m_Database:Quote('Hello'))

m_Database:Query(query) runs any other statement, m_Database:GetError() returns the last error. Always pass values from players through m_Database:Quote().

Setup & Configuration

Installation & Upgrading
Configuration
Maps & Navigation

Contribution

Github Project

Clone this wiki locally