SQL & Persistent Data

The Barracuda Application Server (BAS) provides multiple ways to store data permanently. The best option depends on your application's complexity, performance needs, and deployment environment.

Persistence Options

1. JSON-based persistence: For small or simple data models, serialize Lua tables to persistent storage [1]. This approach is easy to implement and works well when you do not need advanced query capabilities.

2. Embedded SQLite: For larger embedded systems (e.g. Linux and QNX) BAS can run with SQLite embedded in the server [2]. The pre-compiled Mako Server build already includes the SQLite library, so you can start quickly. For setup and usage details, see the SQLite tutorial [3] and API documentation [4].

3. External database drivers: BAS also supports drivers for MySQL, Redis, MongoDB, and PostgreSQL [5]. This option is suitable when you need centralized data, multi-client access, or integration with existing infrastructure. For a practical embedded example, see the ESP32 + MySQL tutorial [6], which shows how a microcontroller can connect to a cloud or on-premises MySQL server.

References

  1. How to serialize Lua tables to a persistent store using JSON, CBOR, etc.
  2. Pre-compiled Mako Server overview
  3. SQLite APIs
  4. SQLite tutorial
  5. Optional database drivers: MySQL, PostgreSQL, etc.
  6. The ESP32 microcontroller and MySQL cloud integration tutorial