JDBC plugin: Doesn’t work when select the table name is a number

Hi Guy

I am using the JDBC plugin and connect to mysql database and I have multiple data table.
The name of table is a number.When I run the logstash config have an error Syntax message:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1' at line 1: SELECT * FROM 1

This is my pipeline:

input {
 jdbc {
   jdbc_driver_library => "C:\Users\nitikarnh\Downloads\logstash-7.6.1\bin\mysql-connector-java-8.0.19.jar"
   jdbc_driver_class => "com.mysql.jdbc.Driver"
   jdbc_connection_string => "jdbc:mysql://localhost:3306/temperature"
   jdbc_user => "infa"
   jdbc_password => "infa"
   schedule => "*/5 * * * * *"
   statement => "SELECT * FROM 1"
   type => "sensor_1"
 }
}

input {
 jdbc {
   jdbc_driver_library => "C:\Users\nitikarnh\Downloads\logstash-7.6.1\bin\mysql-connector-java-8.0.19.jar"
   jdbc_driver_class => "com.mysql.jdbc.Driver"
   jdbc_connection_string => "jdbc:mysql://localhost:3306/temperature"
   jdbc_user => "infa"
   jdbc_password => "infa"
   schedule => "*/5 * * * * *"
   statement => "SELECT * FROM 2"
   type => "sensor_2"
 }
}

output {
 elasticsearch {
   hosts => "http://localhost:5601/"
     index => "sensor"
     document_type => "%{type}" 
 }
 stdout { codec => rubydebug { metadata => true } }
  #stdout { codec =>  "rubydebug"}
}

The rules for MariaDB identifiers say numeric names must be quoted. ("Identifier names may begin with a numeral, but can't only contain numerals unless quoted")

I tried to config
"SELECT * FROM '1'" and
'SELECT * FROM "1"' .
But It doesn't work. Can you show me with the example

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.