Skip to content

UE5 database connectors and virtual file map plugin. (ODBC, OLEDB, LevelDB, LMDB, SQLite, PostgreSQL, Mongo, Redis)

License

Notifications You must be signed in to change notification settings

Frozen-Projects/FF_DB_Connectors

Repository files navigation

FF (Frozen Forest) DB Connectors

A Database Connector plugin for Unreal Engine 5 Windows Platform, providing support for MongoDB, ODBC, OLEDB (SQL Server), PostgreSQL, and Virtual File Mapping at runtime.

Features

MongoDB

A wrapper around the mongocxx driver allowing for standard CRUD operations.

  • Create Connection: Establishes a connection to the MongoDB server.
  • Create Connection String: Helper to format the connection URL.
  • Generic CRUD Operations
    • Get All Collections: Retrieves a list of all collections in the database.
    • Get All Data: Retrieves all documents from a specific collection.
    • Get Data (Filtered): Retrieves specific documents based on filter criteria.
    • Create Collection: Creates a new collection with options.
    • Insert Data: Inserts JSON data into a collection.
    • Update Data: Updates existing documents based on filters.
    • Replace Data: Replaces an entire document based on filters.
    • Find and ...
      • Update: Updates first document that your filter brings but it returns previous state of it.
      • Replace: Replaces first document that your filter brings but it returns previous state of it.
      • Delete: Deletes first document that your filter brings but it returns previous state of it.
  • Monitoring: Monitoring a client, database or collection for changes without blocking game/main thread.
  • Transactions: You can send processes in bulk.
    1. First you need to create a transaction. It will give you a UObject (UMONGO_Transaction_BP). You can create as many as you want.
    2. Each UMONGO_Transaction_BP has a function called Add_Operation_To_Queue_BP. You can define your operation details such as data, filter, operation type (insert, update, replace, delete), database and column name. That function will store details in an array. At this stage there is no mongo related function running.
      • IMPORTANT ! Add_Operation_To_Queue_BP is a generic function that records workflow/query of every operations. Some of them may don't use specific info. (such as delete doesn't have data and insert doesn't have filters.) In these cases you have to define an empty array and select correct operation type from enumerations. Commit function won't use these empty arrays.
    3. When you are done, use Commit_Transaction_BP. It will convert your operation details to actual client_session operation in a for loop and commits it automatically.
    4. After committing, Commit_Transaction_BP will clear old queue. If you want to store them, you can use Print_Operation_Queue_BP before committing.
    5. You can re-use same UMONGO_Transaction_BP after commiting or clearing.

ODBC

Standard SQL connectivity for generic database drivers.

  • Create Connection: Connects to a database using an ODBC driver.
  • Create Connection String: Helper to build the ODBC connection string.
  • Disconnect: Closes the current connection.
  • Execute Query: Runs a SQL query against the database.
  • Learn Columns: Retrieves column metadata (names/types) even if the table is empty.
  • Result Handling:
    • Get Column Info (Names, Types).
    • Get Column Data by Index.
    • Get Column Data by Name.
    • Get Row Data by Index.

OLEDB

Supports high-performance connectivity, specifically optimized for MS SQL Server, with multi-threading support.

  • Create Connection: Establishes a connection via OLEDB provider.
  • Create Connection String: Helper to build the connection string (supports MSOLEDBSQL).
  • Disconnect: Closes the connection.
  • Execute Query: Runs a query asynchronously with AsyncTask (It is good for occasionally execution)
  • Threaded Operations:
    • Start Thread: Initializes a background worker thread specifically for OLEDB.
    • Add Query To Pool: Queues a query to be executed asynchronously on assigned thread. (It is good for high frequency / continues executions)
  • Result Handling: Includes utilities to fetch Columns and Rows similar to the ODBC module.

PostgreSQL

A dedicated connector for PostgreSQL using libpqxx with built-in threading support.

  • Create Connection: Establishes a threaded connection to a PostgreSQL server.
  • Create Connection String: Helper to format the Postgres connection string (supports SSL modes).
  • Add Query To Pool: Queues a SQL query for asynchronous execution.
  • Result Handling:
    • Get Column Info.
    • Get Column Data by Index or Name.
    • Get Row Data by Index.

SQLite

You can't open an SQLite database with write permission more then once. If you open it in anywhere like that, SQLite_Open() will return false !

Virtual File Map (VFM)

A subsystem for handling memory-mapped files, allowing data sharing via system memory.

  • Add File: Maps a file/buffer into memory with custom headers.
  • Remove File: Unmaps and removes the file from memory.
  • Find Other Files: Searches for existing memory-mapped files.
  • Get Files: Retrieves a map of currently managed virtual files.

Generic Tools

Helper functions available globally.

  • SQL To DateTime: Converts SQL standard datetime strings into Unreal FDateTime structs.

Virtual File System (Windows Only)

You have a file or buffer and you want to share them with other processes/apps on same computer with memory address pointing (CreateFileMappingW) and without actual file I/O. But other processes should have correct reading functions.

RoadMap

Connectors that we are certain to integrate.

  • LMDB
  • LevelDB
  • Redis

Connectors that we are investigate.

  • DuckDB