Intermediate 10 min

Persistence & database

Store your bot data (SQLite, MySQL, MongoDB) reliably.

#Database#Persistence#SQL

Ready to start your service? Check offers and order online.

View offers and order

Choose storage

To keep the data between restarts (economy, levels, configs), choose a suitable database:

  • SQLite: simple, local file, ideal to start
  • MySQL / MariaDB: robust, multi-access
  • MongoDB: document oriented

Connection

  1. Install the driver (e.g. better-sqlite3, mysql2, mongoose)
  2. Store identifiers in environment variables
  3. Start connection to boot start

Good practices

  • Never store the identifiers in plain language in the code
  • Manage connection errors and reconnections
  • Save your database regularly (especially SQLite: the file)

File Persistence

With SQLite, the basic file resides in the server files: it is kept between restarts and included in your backups.