MariaDB; sensor 'sensor.maria_database_size' not created

I have defined in ‘yaml’ bdatabase size sensors for both databases - Maria and Influx.
But for some reason sensor for MariaDB size is not created.
Any reason for that?

I have following entry…

# MariaDB Database Sensor
  - platform: sql
    db_url: mysql://homeassistant:123456@core-mariadb/homeassistant?charset=utf8
    queries:
      - name: 'MariaDB DataBase size'
        query: 'SELECT table_schema "database", Round(Sum(data_length + index_length) / 1024, 1) "value" FROM information_schema.tables WHERE table_schema="homeassistant" GROUP BY table_schema;'
        column: 'value'
        unit_of_measurement: MB

#InfluxDB Database Sensor
  - platform: influxdb
    host: a0d7b954-influxdb
    port: 8086
    username: homeassistant
    password: 123456
    scan_interval: 3600
    queries:
      - name: 'InfluxDB Database Size'
        unit_of_measurement: MB
        value_template: "{{ (value | float(0) / 1024 /1024) | round(1) }}"
        group_function: sum
        measurement: '"monitor"."shard"'
        database: _internal
        where: '"database"=''homeassistant'' AND time > now() - 5m'
        field: diskBytes

maria

I will latch on to this thread as I have a similar issue, however in my case the sensor is not created at all.

Here is my code:

#MariaDB Database Sensor
  - platform: sql
    db_url: mysql://homeassistant:passw@core-mariadb/homeassistant?charset=utf8mb4
    scan_interval: 3600
    queries:
      - name: MariaDB Size
        query: SELECT table_schema "database", Round(Sum(data_length + index_length) / 1024 / 1024, 1) "value" FROM information_schema.tables WHERE table_schema="homeassistant";
        column: "value"
        unit_of_measurement: MB

When I run the query in PHPMyadmin’s SQL query box it works 100% and returns the value. In YAML it does nothing and there is no sensor created.

1 Like

Have you tried the query without the single quotes?

https://community.home-assistant.io/t/sensor-mariadb-size-not-working/407753/4

The reply from jwderoode worked for me to install the SQL device integration.

In my case (1st post) the sensor is also not created…
The name and picture you see of this sensor: ‘sensor_mariadb_database_size’ was created manually…
And I still do not know why the sensor is not created.
The syntax of query is O.K.and working… I checked it manually…

Update: followed instruction from provided above link… Now is working…