All Mods Resource Packs Data Packs Shaders Modpacks Plugins
SQLib

SQLib

by mrnavastar • Downloads: 0 • Followers: 0
Description
Gallery
Changelog
Versions

Maintenance PRs Welcome

SQLib

SQLib is the easiest way to store data for all your minecraft needs! A simple sql wrapper made with a focus on minecraft use cases.

Important Note:

This library is not a full-fledged sql wrapper, and does not provide full access to many sql features. The main focus of this library is to provide an easy and simple way to store data in your mods. If you are looking for a more advanced database I recommend taking a look at something like Nitrite.

Config

The mod generates a config on first time start that allows you to configure the database used by all mods relying on sqlib. The default database is a sqlite database running in the sqlib directory.

Datatypes

The datatypes can be accessed via JavaTpes, MinecraftTypes or the AdventureTypes classes. I tend to add support for new types as I run into them in my projects. If you would like one added, pleade make an issue! | Standard | Minecraft | Adventure | |----------|-------------|-----------| | Byte | Vec3i | Key | | Byte[] | BlockPos | Component | | Bool | ChunkPos | | | Short | Text | | | Int | Identifier | | | Float | Sound | | | Double | Json | | | Long | NbtElement | | | String | | | | Char | | | | Date | | | | Color | | | | UUID | | | | URI | | | | URL | | |

You can also add your own custom types as seen here:

Setup

In your build.gradle include:

repositories {
    maven { url "https://api.modrinth.com/maven" }
}

dependencies {
  modImplementation("maven.modrinth:sqlib:3.2.2")
}

Developer Usage

This example uses the built-in database managed by sqlib. for 99% of mods, using the built-in database is good, however further down are examples for custom database management.

// Do not call SQLib.getDatabase() in a early mod initializer. Doing so will likely crash your mod.
// Calling in or after the regular mod initializer is ok.
Database db = SQLib.getDatabase();

DataStore store = db.dataStore("myModId", "userdata");

DataContainer playerData = store.createDataContainer();
playerData.put(JavaTypes.STRING, "username", "CoolGuy123");
playerData.put(MinecraftTypes.BLOCKPOS, "home", new BlockPos(304, 62, 37));
playerData.put(MinecraftTypes.NBT, "nbt", new NbtCompound());

System.out.println(playerdata.get(JavaTypes.STRING, "username"));
System.out.println(playerdata.get(MinecraftTypes.BLOCKPOS, "home"));
System.out.println(playerdata.get(MinecraftTypes.NBT, "nbt"));

Custom Database Management

Postgres db = new Postgres("name", "192.168.1.69", "3306", "cooluser", "radman");
// OR
MySQL db = new MySQL("name", "192.168.1.69", "3306", "cooluser", "radman");
// OR
SQLite db = new SQLite("name", "some/dir");

Transaction Support

This approach will bach sql commands into one command for faster read/writes of large amounts of data.

DataStore store = db.dataStore("modId", "userdata");

DataContainer playerData = table.createDataContainer();
playerData.transaction().put("username", "CoolGuy123").put("home", new BlockPos(304, 62, 37).commit();

Custom Types

You can add a custom type by following the implentations in JavaTypes, MinecraftTypes and AdventureTypes. Then you can use it like any other native SQLib type.

// The SQLPrimitive is the base type to serialize to, and the two function lambdas are to serialize and deserialize from it
public static final SQLibType<JsonElement> JSON = new SQLibType<>(SQLPrimitive.STRING, JsonElement::toString, JsonParser::parseString);

// You can also extend a type like this:
public static final SQLibType<Identifier> IDENTIFIER = new SQLibType<>(SQLPrimitive.STRING, Identifier::toString, Identifier::tryParse);
public static final SQLibType<SoundEvent> SOUND = new SQLibType<>(IDENTIFIER, SoundEvent::getId, SoundEvent::of);

All Versions

+ Add Version
Name Game version Platforms Published Downloads Actions
1.21.x 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21.x 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21.x 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21.x 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21.x 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21.x 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21.x 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21.x 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21.x 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21.x 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.21 1.20.x 1.19.x +3
Fabric Quilt Velocity
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x
Fabric Quilt
13h ago 1
1.20.x
Fabric Quilt
13h ago 1
1.20.x
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric Quilt
13h ago 1
1.20.x 1.19.x 1.18.x +2
Fabric
13h ago 1
1.19.x 1.18.x 1.17.x +1
Fabric Quilt
13h ago 1
1.19.x 1.18.x 1.17.x +1
Fabric Quilt
13h ago 1
1.19.x 1.18.x 1.17.x +1
Fabric Quilt
13h ago 1
1.19.x 1.18.x 1.17.x +1
Fabric Quilt
13h ago 1
1.19.x 1.18.x 1.17.x +1
Fabric Quilt
13h ago 1
[3.2.9] SQLib 3.2.9 by mrnavastar on Oct 15, 2026
Download
  • Allow local database paths to start with / on linux
[3.2.8] SQLib 3.2.8 by mrnavastar on Oct 15, 2026
Download
  • Re work the initial non minecraft api as it was flawed, all issues are hopefully addressed
[3.2.7] SQLib 3.2.7 by mrnavastar on Oct 15, 2026
Download
  • fix silly crash
[3.2.6] SQLib 3.2.6 by mrnavastar on Oct 15, 2026
Download
  • Add two new functions in SQLibConfig that allow for setting the config and default database directory, allowing for sqlib to be used in unsupported mod loads and even outside of minecraft
[3.2.5] SQLib 3.2.5 by mrnavastar on Oct 15, 2026
Download
  • Fix MySql/MariaDB/Postgres not loading correctly on velocity
[3.2.4] SQLib 3.2.4 by mrnavastar on Oct 15, 2026
Download
  • Add a new DataStore function getOrCreateDefaultContainer to cover the most common on create lambda
[3.2.3] SQLib 3.2.3 by mrnavastar on Oct 15, 2026
Download
  • Update to 1.21.2
[3.2.2] SQLib 3.2.2 by mrnavastar on Oct 15, 2026
Download
  • Fix config not generating when using manual database creation
[3.2.1] SQLib 3.2.1 by mrnavastar on Oct 15, 2026
Download
  • fix invalid config creation on windows
[3.2.0] SQLib 3.2.0 by mrnavastar on Oct 15, 2026
Download
  • Get on datacontainers now returns an optional instead of null
  • Move Gson Types into their own class so they can be used without minecraft being present
[3.1.4] SQLib 3.1.4 by mrnavastar on Oct 15, 2026
Download
  • Fix an oversight that could cause problems when null values are retrieved from the database
[3.1.3] SQLib 3.1.3 by mrnavastar on Oct 15, 2026
Download
  • Fix Another crash (we do love testing in prod dont we)
[3.1.2] SQLib 3.1.2 by mrnavastar on Oct 15, 2026
Download
  • Fix a different crash
[3.1.1] SQLib 3.1.1 by mrnavastar on Oct 15, 2026
Download
  • Fix crash
[3.1.0] SQLib 3.1.0 by mrnavastar on Oct 15, 2026
Download
  • Change DataStore Lookup functions to use optionals instead of returning null for that sweet sweet functional goodness
[3.0.6] SQLib 3.0.6 by mrnavastar on Oct 15, 2026
Download
  • Change the way the mod/plugin is loaded internally, allowing SQLib.getDatabase() to be called much earlier
  • Update MariaDB Driver
[3.0.5] SQLib 3.0.5 by mrnavastar on Oct 15, 2026
Download
  • Velocity actually works now
[3.0.4] SQLib 3.0.4 by mrnavastar on Oct 15, 2026
Download
  • Add an optional onCreate function to the DataStore.getOrCreateContainer() functions
[3.0.3] SQLib 3.0.3 by mrnavastar on Oct 15, 2026
Download
  • Allow DataStores and DataContainers to be compared using .equals()
  • Make the transaction commit return a DataContainer
[3.0.2] SQLib 3.0.2 by mrnavastar on Oct 15, 2026
Download
  • Fix crash when getContainer() fails
[3.0.1] SQLib 3.0.1 by mrnavastar on Oct 15, 2026
Download
  • Add a DataContainer lookup function to DataStore that was missed in the api rewrite
[3.0.0] SQLib 3.0.0 by mrnavastar on Oct 15, 2026
Download
  • Rewrite the api to be more user friendly
  • Allow users to define custom datatypes
  • More built in datatypes
  • Postgres support
  • Velocity support
  • fix text for 1.20.5 +
[2.2.13] SQLib 2.2.13 by mrnavastar on Oct 15, 2026
Download
  • Relocate Jackson Data bind packages to improve compatibility with other mods
[2.2.12] SQLib 2.2.12 by mrnavastar on Oct 15, 2026
Download
  • Add Forge Support!
  • Change stopping behaviour to very end of jvm (allows regular game stopping events to be used for saving sql data)
  • Make jar smaller : )
[2.2.11] SQLib 2.2.11 by mrnavastar on Oct 15, 2026
Download
  • Fix compat with old versions (back down to 1.16.5)
[2.2.10] SQLib 2.2.10 by mrnavastar on Oct 15, 2026
Download
  • ~~Fix compat with old versions (back down to 1.16.5)~~
  • Add support for paper, folia, purper, spigot and bukkit
  • Fix crash when using mod on client
[2.2.9] SQLib 2.2.9 by mrnavastar on Oct 15, 2026
Download
  • Allow Chaining of DataContainer .put() calls
  • Allow users to try catch around DataContainer .get() calls instead of just printing an error
[2.2.8] SQLib 2.2.8 by mrnavastar on Oct 15, 2026
Download
  • Update to 1.20.3/4
  • Marked as alpha because it breaks version support for 1.20.2 and below
[2.2.7] SQLib 2.2.7 by mrnavastar on Oct 15, 2026
Download
  • Use connection pooling to reduce connection errors when the mod stays online for many hours.
[2.2.6] SQLib 2.2.6 by mrnavastar on Oct 15, 2026
Download
  • Hey look at that mysql is actually working (ShadowJar moment)
  • Switch over the mysql to the mariadb driver cause its more compatible
  • Fix broken transactions on mysql/mariadb
SQLib Icon
Download SQLib
Select game version
Select platform