DROP TABLE IF EXISTS "main"."{table}";

CREATE TABLE IF NOT EXISTS "main"."{table}" (
    "id" INTEGER NOT NULL UNIQUE,
    "hash" TEXT,
    "timestamp" INTEGER,
    "year" INTEGER,
    "month" INTEGER,
    "day" INTEGER,
    "hour" INTEGER,
    "minute" INTEGER,
    "second" INTEGER,
    "microsecond" INTEGER,
    "org_content_size" TEXT,
    "req_address" TEXT,
    "req_content_size" INTEGER,
    "req_count" INTEGER,
    "req_host" TEXT,
    "req_method" TEXT,
    "req_path" TEXT,
    "req_port" TEXT,
    "req_protocol" TEXT,
    "req_scheme" TEXT,
    "ogc_service" TEXT,
    "ogc_workspace" TEXT,
    "ogc_layers" TEXT,
    "ogc_request" TEXT,
    "ogc_epsg" TEXT,
    PRIMARY KEY("id" AUTOINCREMENT)
);

INSERT INTO "main"."{table}"
("hash", "timestamp", "year", "month", "day", "hour", "minute", "microsecond", "org_content_size", "req_address", "req_content_size", "req_count", "req_host", "req_method", "req_path", "req_port", "req_protocol", "req_scheme", "ogc_service", "ogc_workspace", "ogc_layers", "ogc_request", "ogc_epsg")
VALUES 
(:hash, :timestamp, :year, :month, :day, :hour, :minute, :microsecond, :org_content_size, :req_address, :req_content_size, :req_count, :req_host, :req_method, :req_path, :req_port, :req_protocol, :req_scheme, :ogc_service, :ogc_workspace, :ogc_layers, :ogc_request, :ogc_epsg);

SELECT id, hash, timestamp, year, month, day, hour, minute, microsecond, org_content_size, req_address, req_content_size, req_count, req_host, req_method, req_path, req_port, req_protocol, req_scheme, ogc_service, ogc_workspace, ogc_layers, ogc_request, ogc_epsg FROM {table};

SELECT id, hash, timestamp, year, month, day, hour, minute, microsecond, org_content_size, req_address, req_content_size, req_count, req_host, req_method, req_path, req_port, req_protocol, req_scheme, ogc_service, ogc_workspace, ogc_layers, ogc_request, ogc_epsg FROM {table} WHERE service <> '';

SELECT id, hash, timestamp, year, month, day, hour, minute, microsecond, org_content_size, req_address, req_content_size, req_count, req_host, req_method, req_path, req_port, req_protocol, req_scheme, ogc_service, ogc_workspace, ogc_layers, ogc_request, ogc_epsg FROM {table} WHERE service = '';

SELECT id, hash, timestamp, year, month, day, hour, minute, microsecond, org_content_size, req_address, req_content_size, req_count, req_host, req_method, req_path, req_port, req_protocol, req_scheme, ogc_service, ogc_workspace, ogc_layers, ogc_request, ogc_epsg FROM {table} WHERE request = 'getmap';


CREATE TABLE IF NOT EXISTS "main"."{table}" (
    "id" INTEGER NOT NULL UNIQUE,
    "id_logs" INTEGER,
    "service" TEXT,
    "workspace" TEXT,
    "layer" TEXT,
    "request" TEXT,
    "epsg" TEXT,
    PRIMARY KEY("id" AUTOINCREMENT)
);
