Ad Widget

Collapse

mysql.custom.query specifying the database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rebane
    Junior Member
    • Oct 2023
    • 1

    #1

    mysql.custom.query specifying the database

    Hello all,

    I have a question regarding the mysql.custom.query item key. I'm trying to make some alerts based on this key, just like I did with PostgreSQL and its' agent2 plugin. But I ran into a small problem.

    For psql.custom.query, you are able to specify the database the query is run on, as the item key accepts it as a parameter {$PG.DATABASE}. For mysql.custom.query, an equivalent parameter however does not seem to exist. Because of this I cannot get my items to work, they always return error database not selected as mysql does not know which database to run the query on.

    So my question is how are you supposed to specify the database? I tried to specify it in the data source name, like tcp://127.0.0.1:3306/dbname , but the last part is just ignored. I tried to write it into the customquery.sql file like
    Code:
    USE dbname; SELECT * FROM table;
    but this returns SQL syntax error, as I'm sure it accepts only 1 query at a time.

    Any suggestions? Thank you in advance.
    Last edited by Rebane; 08-12-2023, 09:46.
  • andrnils
    Junior Member
    • Feb 2024
    • 1

    #2
    I don't know if you solved it yet, but I'm also trying to use mysql custom query. I can select database like this:
    Code:
     SELECT * from databasename.table ;

    Comment

    Working...