7.23. sql: Storing messages in an SQL database
sql() driver sends messages into an SQL database. Currently the Microsoft SQL (MSSQL), MySQL, Oracle, PostgreSQL, and SQLite databases are supported.
sql(database_type host_parameters database_parameters [options]);
The syslog-ng application requires read and write access to the SQL table, otherwise it cannot verify that the destination table exists.
Currently the syslog-ng application has default schemas for the different databases and uses these defaults if the database schema (for example columns and column types) is not defined in the configuration file. However, these schemas will be deprecated and specifying the exact database schema will be required in later versions of syslog-ng.
value parameters can include macros to create tables and columns dynamically (for details, see Section 11.1.5, Macros of syslog-ng OSE).
When using macros in table names, note that some databases limit the maximum allowed length of table names. Consult the documentation of the database for details.
Inserting the records into the database is performed by a separate thread. The syslog-ng application automatically performs the escaping required to insert the messages into the database.