mod_storage_sql
SQL database storage backend for Prosody.
Details
mod_storage_sql allows Prosody to connect to an SQL database to store data. Officially supported databases are SQLite3, MySQL and PostgreSQL.
Usage
Firstly, ensure you have the LuaDBI library available on your system. For information on how, refer to our documentation on dependencies.
Then add the following to your config file:
= "sql"
storage = {
sql = "PostgreSQL"; -- May also be "MySQL" or "SQLite3" (case sensitive!)
driver = "prosody"; -- The database name to use. For SQLite3 this the database filename (relative to the data storage directory).
database = "localhost"; -- The address of the database server (delete this line for Postgres)
host = 3306; -- For databases connecting over TCP
port = "prosody"; -- The username to authenticate to the database
username = "secretpassword"; -- The password to authenticate to the database
password }
Table management
If Prosody has the necessary permissions it will automatically initialize the database (creating tables and indexes) when you point it to a new empty database. Any schema upgrades will also be automatic.
In particular it is recommended that you grant Prosody the following SQL permissions on its database: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX.
If you do not wish Prosody to attempt automatic table and schema management, set sql_manage_tables to false in your config.
For information on the database schema, please see our mod_storage_sql developer documentation.
Configuration
Option | Default | Notes |
---|---|---|
sql | { driver = "SQLite3", database = "prosody.sqlite" } | Configure the database to use (see above). |
sql_manage_tables | true | Specifies whether Prosody will automatically create/update the tables it needs (recommended). |