Skip to content
LODS edited this page Mar 4, 2023 · 5 revisions

Welcome to the DB Manager wiki! (a Lua version inspired by Sequelize)

In this guide, we will be exploring a powerful ORM (Object-Relational Mapping). Whether you're new to Lua or an experienced developer, this wiki will provide you with the necessary knowledge to effectively utilize this tool in your projects. So let's dive in and explore the features and capabilities of this Lua DB Manager!

Quick Example

local conn = DBManager:new({
    dialect = "mysql",
    host = "localhost",
    port = 3306,
    username = "root",
    password = "123456",
    database = "test_db_manager",
})

if (not conn:getConnection()) then
    error("DBManager: Connection failed", 2)
end

local Users = conn:define("Users", {
    id = {
        type = DBManager.INTEGER,
        allowNull = false,
        autoIncrement = true,
        primaryKey = true,
    },
    name = {
        type = DBManager.TEXT(),
        allowNull = false,
    }
})

Users:sync()
Users:create({ name = "LODS" }) -- create a new user with name LODS.
Clone this wiki locally