Database SQL Workbench Plugin for Godot Engine
English | 简体中文
A database SQL workbench plugin for Godot Engine built on top of the ConfigFile system. It provides a visual database management interface, Excel-like data editing, a full SQL query engine, a MyBatis-style ORM mapping framework (GBatis), and AES-256-CBC data encryption. Pure GDScript, zero external dependencies, no database server required.
Complete database operations through GDScript method chaining — no XML required:
# Select
var result = GDSQL.BaseDao.new() \
.use_db("GameConfig") \
.select("id, name, hp, mp", true) \ # Or: .select("id", "name", "hp", "mp", true) Or: .select("*", true)
.from("c_hero") \
.where("hp > 100 AND mp >= 50") \
.order_by("hp") \
.limit(10) \
.query()
# Insert
GDSQL.BaseDao.new() \
.use_db("GameConfig") \
.insert_into("c_hero") \
.values({"id": 101, "name": "NewHero", "hp": 200}) \
.query()
# Update
GDSQL.BaseDao.new() \
.use_db("GameConfig") \
.update("c_hero") \
.sets({"hp": 300}) \
.where("id == 101") \
.query()
# Delete
GDSQL.BaseDao.new() \
.use_db("GameConfig") \
.delete_from("c_hero") \
.where("id == 101") \
.query()Parse and execute any SQL string directly — the parser returns a ready-to-run BaseDao:
# SELECT
var dao = GDSQL.SQLParser.parse_to_dao("SELECT id, name, hp FROM GameConfig.c_hero WHERE hp > 100 ORDER BY hp DESC")
var result = dao.query()
if result and result.ok():
var head = result.get_head() # ["id", "name", "hp"]
var rows = result.get_data() # [[1, "Warrior", 200], ...]
for row in rows:
print(row)
# INSERT
GDSQL.SQLParser.parse_to_dao("INSERT INTO GameConfig.c_hero (id, name, hp) VALUES (101, 'Mage', 80)").query()
# UPDATE
GDSQL.SQLParser.parse_to_dao("UPDATE GameConfig.c_hero SET hp = 300 WHERE id == 101").query()
# DELETE
GDSQL.SQLParser.parse_to_dao("DELETE FROM GameConfig.c_hero WHERE id == 101").query()SQL keywords are case-insensitive. The parser includes an LRU cache (1024 entries) so repeated queries are faster.
QueryResult wraps query output with status checks and data access:
var result = GDSQL.BaseDao.new() \
.use_db("GameConfig") \
.select("id, name, hp", true) \
.from("c_hero") \
.where("hp > 100") \
.query()
if result and result.ok():
var head = result.get_head() # Column names: ["id", "name", "hp"]
var data = result.get_data() # Rows: [[1, "Warrior", 200], ...]
print("Row count: ", result.size())
for row in data:
var name = row[head.find("name")]
print(name)
else:
print("Query failed: ", result.get_err() if result else "null")Reference tables from other databases using database.table notation:
var dao = GDSQL.SQLParser.parse_to_dao("SELECT * FROM UserData.t_hero t1 LEFT JOIN GameConfig.c_hero t2 on t2.id == t1.hid WHERE t1.hp > 100")
var result = dao.query()var dao = GDSQL.SQLParser.parse_to_dao("SELECT name, AVG(hp) as avg_hp FROM GameConfig.c_hero GROUP BY name WHERE avg_hp > 100")
var result = dao.query()var dao = GDSQL.SQLParser.parse_to_dao("SELECT a.id, a.name, b.score FROM GameConfig.c_hero a LEFT JOIN c_score b ON a.id == b.hero_id WHERE b.score > 50")
var result = dao.query()- Full SQL syntax: SELECT / INSERT / UPDATE / DELETE / REPLACE
- Conditional queries: WHERE, AND, OR, IN, NOT IN, Godot built-in operator or function (eg. contains)
- Sorting & grouping: ORDER BY, GROUP BY
- Pagination: LIMIT, OFFSET
- Joins: LEFT JOIN with chainable multi-table support; Cross database join query!
- Set operations: UNION ALL
- Aggregate functions: COUNT, SUM, AVG, MIN, MAX, GROUP_CONCAT, and more
- Expression evaluation: SQL-compatible null semantics, operators, function calls, type conversion
- LRU cache: Auto-caches the last 1024 parsed SQL statements
Available as a dedicated main screen in the Godot Editor:
- Database tree browser: Navigate all databases and tables in a tree view
- Data table viewer: Browse and edit data in an Excel-like grid
- Inline editing: Modify data directly in table cells with instant effect
- Drag-to-resize columns: Freely adjust column widths
- Table structure editor: View and modify column definitions, types, defaults, and comments
- Schema management: Visually create / delete / edit databases and tables
- Data import/export: CSV, JSON, and CFG formats
- Diff view: Compare table content with highlighted additions, deletions, and changes
- SQL query editor: Write and execute SQL with automatic query history
- Export query results: Export results as CSV, JSON, or CFG
- Least-squares fitting: Predicts and fills subsequent data based on existing samples
- Multi-type support: Numbers, strings (with numeric placeholders), Vector2/3/4, Vector2i/3i/4i, Resource paths
- Pattern recognition: Detects numbering patterns (e.g.
"name_001","name_002") and fills accordingly
A drag-and-drop graph editor for designing table relationships:
- Node-based editing: Display tables as graph nodes with free-form layout
- One-click code generation:
- Entity class (
.gd): Auto-generatedclass_nameentity with typed properties - XML mapping file (
.xml): Complete GBatis mapping - Mapper Graph file (
.gdmappergraph): Persisted layout and relationships
- Entity class (
- Type inference: Database column types → GDScript types
- Relationship visualization: Lines show foreign-key connections
- Incremental sync: Detects schema changes and highlights differences
- AES-256-CBC: Built on Godot's native
AESContext - DEK hierarchy: Data encryption key + user password dual-layer protection
- Key derivation: HMAC-SHA256 with random salt
- Verification: Built-in verify code detects wrong passwords
- Flexible granularity: Database-level and table-level encryption
- Editor support: Encrypted files require a password to view in-editor
- Built-in XML editor with syntax highlighting
- Find and replace
- Tree view navigation and multi-tab editing
13 languages: Simplified Chinese, Traditional Chinese, English, Japanese, Korean, French, German, Spanish, Italian, Portuguese (BR), Russian, Polish, Turkish.
| Feature | GDSQL | SQLite / GDSQLite | Custom Resource |
|---|---|---|---|
| Storage | .cfg plain text |
Binary | .tres / .res |
| SQL queries | Full syntax | ✅ | ❌ |
| Visual editor | Built into Godot | Third-party | Built into Godot |
| Excel-like editing | Inline + auto-fill | ❌ | ❌ |
| ORM mapping | ✅ GBatis | ❌ | ❌ |
| Code generation | Entity + XML mapping | ❌ | ❌ |
| Runtime CRUD | Fluent API / GBatis | SQL | ❌ |
| Encryption | AES-256-CBC | Manual | Godot built-in |
| VCS friendly | Plain text, diffable | Binary | Diffable |
| No external services | ✅ | ✅ | ✅ |
| Cross-platform | Godot everywhere | Needs compilation | Godot everywhere |
-
Zero external dependencies — No database engine, no database server, no additional runtime. Install as a plugin and it works.
-
ConfigFile-based storage — All data lives in
.cfgplain text files, Godot's native format. Version control friendly (git diff), editable in any text editor, accessible outside the Godot editor. -
Unified editor & runtime API — The same API works in-editor for development and in the exported game for runtime access. No need to maintain two data access layers.
-
Dual development modes — Use the fluent DAO API for quick data access, or GBatis XML mapping files for complex queries and result mapping.
-
End-to-end ORM pipeline — From visual graph editor to auto-generated entity classes and mapping files to runtime CRUD. Developers focus on business logic while the tool handles the boilerplate.
-
Excel-grade data editing — Inline cell editing, draggable columns, long-content viewing, and smart auto-fill dramatically improve editing efficiency.
-
Built-in security — Sensitive game data can be encrypted directly at the plugin level.
-
All-in-one solution — A single plugin covers data definition, management, querying, editing, encryption, and code generation.
See CONTRIBUTING.md for development setup, including the pre-push git hook for manifest management.
- Place this repository into your Godot project's
addons/directory - Enable GDSQL in Godot Editor → Project Settings → Plugins
- Click the GDSQL main screen button at the top of the editor
- Create databases and tables in the workbench
- Use
GDSQL.BaseDaoor GBatis for runtime queries
GBatis is the built-in ORM framework, fully implementing MyBatis 3 capabilities. SQL statements live in XML mapping files, completely separate from GDScript code — ideal for complex queries and object mapping.
GBatis supports two working modes:
- Manual authoring: Advanced users can fully customize XML and entity code for fine-grained control
- Visual generation: The built-in Mapper Graph editor lets you design relationships through drag-and-drop, then generate initial versions with one click:
- XML mapping files (
.xml): Complete resultMap and dynamic SQL - Entity class code (
.gd):class_nameGDScript class with typed properties - Mapper Graph file (
.gdmappergraph): Persisted node layout for incremental updates
- XML mapping files (
The two approaches can be combined: quickly scaffold with the visual editor, then manually fine-tune.
- XML mapping files: SQL in XML, decoupled from code
- Dynamic SQL:
<if>,<where>,<set>,<foreach>,<trim>,<bind> - Result mapping:
<resultMap>for complex nested object mapping - Associations & collections: One-to-one and one-to-many via
<association>/<collection> - Discriminator: Polymorphic mapping based on field values
- L1 / L2 caching: Configurable cache for query performance
- Auto-mapping: NONE and PARTIAL levels
- useGeneratedKeys: Auto-populate generated primary keys
- Multi-parameter binding: Named and positional parameter support
<mapper namespace="HeroMapper">
<resultMap id="heroResult" type="HeroEntity">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="hp" column="hp"/>
<result property="mp" column="mp"/>
</resultMap>
<select id="selectHeroesByHp" resultMap="heroResult">
SELECT * FROM c_hero WHERE hp > #{minHp} ORDER BY hp DESC
</select>
</mapper>Create a class extending GBatisMapper and point its mapper_xml property to the XML file above. The SQL methods become directly callable.
| Scenario | Recommended | Why |
|---|---|---|
| Simple CRUD | Fluent DAO | Concise, no extra files |
| Complex queries / joins | GBatis | SQL-code separation, powerful mapping |
| Team collaboration | GBatis | DBA handles XML, devs call methods |
| Rapid prototyping | Fluent DAO | Zero config, write and use |
- Performance ceiling: As a pure GDScript implementation, GDSQL is not designed for real-time high-throughput scenarios.
- Data volume: Optimized for game configuration data (hundreds to tens of thousands of records), not for data warehouses or datasets exceeding hundreds of thousands of rows.
- Concurrent access: The ConfigFile-based engine does not support multi-threaded concurrent writes. All operations should run on the main thread.
- No server mode: Local-only, file-based data store. No network access, no client-server architecture, no multi-user concurrency.
- No referential integrity: Foreign key relationships exist at the application level; the storage engine itself does not enforce constraints.
- Limited indexing: Indexes are maintained in memory via
ImprovedConfigFile.set_indexed_props()— no persistent index structure.
- Performance roadmap: Identify hot paths and optimize — both GDScript-level and via GDExtension for critical sections
- Extended SQL syntax: Window functions, CTEs (Common Table Expressions), full JOIN support (INNER, RIGHT, FULL)
- Query planner optimization: Better execution order, LEFT JOIN predicate push-down
- More ease-of-use features: Simplify common workflows, lower the learning curve
- Quality-of-life improvements: Better error messages, undo/redo, batch operations, enhanced keyboard shortcuts
- Comprehensive documentation site: Dedicated API reference, tutorials, and real-world examples
- Testing infrastructure: Expanded unit test coverage and integration tests for the full query lifecycle