diff --git a/sbcl-nginx.yml b/sbcl-nginx.yml index 118b9e4..ad2375b 100644 --- a/sbcl-nginx.yml +++ b/sbcl-nginx.yml @@ -421,11 +421,17 @@ write_files: # Increase history limit set -g history-limit 50000 - - path: /home/cl/nginx_logs.sql + - path: /home/cl/access_logs.sql owner: 'cl:cl' defer: True content: | - CREATE TABLE nginx_logs ( + -- commands.sql + + -- Set the mode to CSV to properly import CSV files + .mode csv + + -- If the table doesn't exist, create it + CREATE TABLE IF NOT EXISTS access_logs ( timestamp TEXT, ip_address TEXT, remote_user TEXT, @@ -436,6 +442,9 @@ write_files: http_user_agent TEXT ); + -- Import the data into the 'access_logs' table + .import '/var/log/nginx/access.csv' access_logs + - path: /home/cl/setup_sbcl.sh owner: 'cl:cl' permission: '0755'